-
A PV operation consists of a P operation primitive and a V operation primitive (primitives are uninterruptible processes). The semaphore is defined as follows: p(s): Subtract 1 from the value of the semaphore, i.e., ss
If s0, the process continues; Otherwise, the process is placed in the waiting state and queued for the process.
v(s): Add 1 to the value of the semaphore, i.e. ss
If s0, the process continues; Otherwise, the first process in the queue to wait for semaphores is released.
Significance of PV operation: We use semaphore and PV operation to achieve process synchronization and mutual exclusion. PV operations belong to the low-level communication of the process.
The data structure of a semaphore is a value and a pointer that points to the next process waiting for that semaphore. The value of the semaphore is related to the usage of the corresponding resource. When its value is greater than 0, it indicates the number of currently available resources; If its value is less than 0, its absolute value indicates the number of processes waiting to use the resource.
Note that the value of the semaphore can only be changed by the PV operation.
In general, semaphores
At 0, s indicates the number of available resources. Performing a p operation means that a request is allocated a unit resource, so the value of s is minus 1; When s<0 is used, it means that there are no resources available, and the requester must wait for other processes to release the resources before it can run. Performing a v operation means releasing a unit of resource, so the value of s is increased by 1; If s
0, indicating that some processes are waiting for the resource, so you need to wake up a waiting process to make it run. In other words, there is an unoccupied resource that allows a blocking process to execute, rather than a s that can be executed. For more information on how to use the implementation on the specific system, please refer to UNIX Network Programming Volume 2:
Inter-process communication.
-
Answer]: According to the definition of the semaphore, it can be seen that the p and v operations are not only the subtraction of 1 or the addition of 1 to the semaphore, but more importantly, the result of the operation is also judged after subtracting 1 or adding 1. For the p operation trace, the calling process itself may continue to run after the decision, or it may block the waiting.
For v operations, the calling process itself always ends up running after the decision, but may wake up the process waiting on the semaphore queue beforehand.
In terms of semaphore, it can perform any other operations except P and V operations.
-
1: You didn't describe it clearly.
2: If two or even more cars are visiting the self-parking machine at the same time, then the only parking space will be visited by the conflict.
--Visiting this parking device is not the same as obtaining an entry permit for the parking device. In practice, what must be needed when accessing, the access itself is not mutually exclusive, "access and obtain an entry permit" is an atomic operation, a whole. For example, the semaphore s = 1, and the value of s is 1, which means that the other person has already obtained it, so he cannot obtain it.
The value of read s can be concurrent, but modifying the value of s is an atomic operation.
3: You can understand it if you look at the source**, only a few lines**.
Reading books, looking at these analogy examples, it is always easy to get confused.
I haven't really encountered this kind of problem.,It's normal for you to hang your head if you're using IE! It is recommended to restore all the values of the Internet option to the default, and if it is IE7, you can try to upgrade to IE8 to see if the problem can be solved, good luck! If you want to upgrade to IE8, you can use Windows Update to upgrade, or go to Microsoft's official website**!
There is only a reinstall system for changing the system, and it is not troublesome to reinstall the system, you haven't installed it, quack. There's always a first time, so go ahead and try it.
Computer operating system, can be divided into three types, UNIX series, Linux series, Windows series, now Windows series with a lot of people, and it is easier to get started, it is more successful in terms of graphical operation interface! At the same time, its security is not very good, as a server system, it still uses relatively high security Linux, or UNIX operating system, these two operating systems, now also support graphical interfaces. Windows series are common, Windows XP, Windows Me, Windows 2000, Windows NT, Windows Server2003, Windows 2000 Server >>>More
This path exists regardless of the version, but if it exists in your current user, it depends on whether your current user is administrator or not. Also, the versions of XP are Home and Professional, and each version is divided into SP1 and SP2 versions. It is recommended that you find the SP2 version to install, if you will modify the motherboard BIOS, it is best to install the OEM version, no activation.
Microsoft has gone through 30 years from the first generation of Windows operating system in 1985 to Windows 10, and the changes in between are really innumerable, but it is Microsoft's unchanging pursuit and efforts from the beginning of the period, listening to users' voices and making modifications, to achieve the prosperity of the later XP era. >>>More