More info. on Semaphores
-
A semaphore consists of the following
-
an integer value (e.g. int count)
-
two atomic (i.e. indivisible) operations: down (P) and up (V)
-
Definition: down (P)
if (count == 0) sleep(); /* put process to sleep on rsource wait queue
*/
v--; /* remove resource and use (e.g. enter the critical section)
*/
-
Definition: up (V)
v++; /* add resource */
wakeup(); /* wakeup all sleeping processes waiting for resource */
This page is maintained by Christopher
A. Gantz (cag@cs.du.edu).