ALL > Computer and Education > courses > university courses > undergraduate courses > Operating System > ZSTU-(2020-2021)-1 > student homework > 2018329621140诸宇晨 >
homework6 Version 0
👤 Author: by 1403861656qqcom 2020-11-09 14:29:05
Semaphore: The semaphore is one of the earliest mechanisms used to solve the same process step and mutual exclusion problem.

A Semaphore consists of a value and a pointer to the process waiting for the Semaphore. The value of the semaphore represents the usage of the corresponding resource. When the semaphore S≥0, S represents the amount of available resources.

Performing a P operation means that a resource is requested, so the value of S is subtracted by 1; When S<0, the resource is no longer available, and the absolute value of S represents the number of processes currently waiting for the resource. The requester must wait for another process to release the resource before continuing.

Performing a V operation means freeing a resource, so the value of S increases by 1; If S<0, some process is waiting for the resource, so you need to wake up a waiting process to run.

Note: The value of the semaphore can only be changed by PV operation.

Please login to reply. Login

Reversion History

Loading...
No reversions found.