In the operating system, how the respective actions of P and V actions are defined

Updated on technology 2024-03-27
3 answers
  1. Anonymous users2024-02-07

    Semaphore. minus 1, i.e., s=s-1;

    If s 0, the process continues;

    If S 0, the state of the process is set to a blocking state, the corresponding PCB is connected to the end of the semaphore queue, and the processor is abandoned and waits (until the other process performs V operation on S and releases it).

    v operations perform the following two actions in the following order:

    S value plus 1, i.e. s=s+1;

    If s 0, the process continues to run;

    If S 0, the process corresponding to the first PCB on the semaphore queue (i.e., the PCB pointed to by the semaphore indicator pointer) is released (changing the blocking state to the ready state), and the process that performed the V operation continues to run.

    Operate. Meaning: PV operations are defined by P operation primitives.

    and v operation primitives (primitives are uninterruptible processes) to operate on semaphores, as defined below:

    p(s): subtract 1 from the value of the semaphore, i.e. s=s-1;

    If s 0, the process continues; Otherwise, the process is placed in the waiting state and queued for the process.

    v(s): Add the value of the semaphore s by 1, i.e. s=s+1;

    If s 0, the process continues; Otherwise, the first process in the queue to wait for semaphores is released.

    Significance of operation: We use semaphore and PV operations to achieve process synchronization and mutual exclusion. PV operations belong to the low-level communication of the process.

    What is Semaphore? The data structure of the 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; When 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.

    3. Generally speaking, when the semaphore is 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, it means that some process is waiting for the resource, so you need to wake up a waiting process to keep it running.

  2. Anonymous users2024-02-06

    Meaning of PV operation: PV operation consists of P operation primitives and V operation primitives (primitives are uninterruptible processes), which operate on semaphores, which are defined as follows:

    p(s): subtract 1 from the value of the semaphore, i.e. s=s-1;

    If s 0, the process continues; Otherwise, the process is placed in the waiting state and queued for the process.

    v(s): Add the value of the semaphore s by 1, i.e. s=s+1;

    If s 0, 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.

    What is Semaphore? 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, when the semaphore is 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, it means that some process is waiting for the resource, so you need to wake up a waiting process to keep it running.

  3. Anonymous users2024-02-05

    The statement about p-v operation is wrong with the side rule ().

    The operation shirt is a more flexible base system than the lock mechanism.

    Actions can be used to control synchronization and mutual exclusion between processes.

    At the heart of the operation are two functions that are used to control the semaphore and the process in or out.

    Both the operation and the v operation will add the semaphore by 1.

    Correct answer: Both p and v operations will add the semaphore by 1.

Related questions
9 answers2024-03-27

Nowadays, there are three major camps of mobile phone operating systems: symbian, Microsoft, and Linux. >>>More

6 answers2024-03-27

Answer]: The research on the security protection of the operating system usually includes the following contents: First, the security functions and security services provided by the operating system itself. >>>More

5 answers2024-03-27

nicolasff/phpredis/downloads2.**After there are two modules in it that are compiled by VC6 and VC9, we need to know whether our PHP is VC6 or VC9: create a new one and click (here) to collapse or open 3 >>>More

14 answers2024-03-27

It seems that there are some folders that have privileged instructions, such as: ** station. >>>More

7 answers2024-03-27

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.