Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Three types of operating system precursor diagrams summarize in detail how process management uses PV operations

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "how to use PV operation in process management of three kinds of operating system precursor diagram types in detail." In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

PV Operation Definition

S in this paper is a semaphore. The basics of precursor graphs and semaphores are not described in detail in this article.

1.1 P operation definition

S:=S-1, if S≥0, then the process performing the P operation continues; if S0, then the process performing the V operation continues; if S≤0, then a process is awakened from the blocking state and inserted into the ready queue, and then the process performing the V operation continues.

With this long definition, we just need to remember that the process performing the V operation will wake up a process from the blocking queue.

II. Series process (one-line precursor diagram)

2.1 What is a one-line precursor diagram?

Cascading processes (single-line precursor diagrams) are the simplest of the operations to compute PV. What is a one-line precursor diagram? An example precursor diagram is as follows:

Trunk information: The process executed by PV operation control processes P1, P2 and P3 is set to two semaphores S1 and S2 respectively, and the initial values are zero. List the process execution diagrams for each of the three processes to calculate PV operations for each process.

We can see that P1, P2, P3 three processes are series relationship, one by one execution, only the previous process to execute the latter can be executed, we will classify this type of precursor diagram as a single-line precursor diagram.

2.2 How do I calculate PV of a single precursor diagram?

So what do we do to compute PV operations for that process? We divide the nodes into precursor nodes (i.e., the first node), intermediate nodes, and tail nodes to calculate PV.

2.2.1 Calculate precursor PV

For the predecessor head-node process P1, the result of process P1 performing operations from the initial state is to wake up a process from the blocking queue, i.e. wake up P2, so it only has V operations, occupying a semaphore S1, and process P1 performs V (S1) operations. The P1 process execution diagram is shown in the following figure:

2.2.3, computing tail node PV

For P3 process, similarly, it can only be executed after the predecessor node P2 completes the transmission of the semaphore S2, and then the process ends. The P3 process execution diagram is shown in the following figure:

Title stem information: Use PV operation to control the concurrent execution of processes P1, P2, P3 and P4, and set four semaphores as S1, S2, S3 and S4 respectively with initial values of zero. List the process execution diagrams for each of the five processes to calculate PV operations for each process.

3.2.1 Calculate precursor PV

For the first node of the predecessor, take the process P1 as an example. The result of the process P1 performing the operation from the initial state is to wake up a process from the blocking queue, that is, wake up P4, so it only has V operation and occupies a semaphore S1, so the process P1 performs V (S1) operation. The P1 process execution diagram is shown in the following figure:

3.2.2 Calculate intermediate PV

For the intermediate node process P4, it can only be executed after the predecessor processes P1, P2, and P3 have all been completed, and the processes P1, P2, and P3 may all be in the blocking queue, so the process P4 needs to wait for the execution of the processes P1, P2, and P3 (i.e., the P operation) to receive the semaphore, and then execute the process P4 itself to wake up the operation P5 (i.e., the V operation) to occupy a semaphore S4. The P4 process execution diagram is shown in the following figure:

3.3 Parallel processes tend to unfold

Parallel processes tend to unfold is one of the more difficult parallel processes, but sorting out thoughts is still handy. Examples are as follows:

3.3.2 Calculate intermediate PV

For process P2, it is necessary to wait for semaphore S1 of P1 and wake up processes P3 and P4 occupying semaphore S1 and S2 respectively. The P2 process execution diagram is shown in the following figure:

For process P4, it is necessary to wait until semaphores S3, S4 of processes P2, P3 can be executed, and then activate process P5 and occupy a semaphore S5. The P4 process execution diagram is shown in the following figure:

"Three operating system precursor diagram types detailed summary process management of how to use PV operation" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 275

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report