Semaphores, Operating System

Synchronization can be achieved by means other than locks and condition variables. One alternative is semaphores. A semaphore is used to regulate traf?c in a critical section. A semaphore is implemented as a non-negative integer counter with atomic increment and decrement operations, up() and down(), respectively. Whenever the decrement operation would make the counter negative, the semaphore blocks instead.  down(sem): tries to decrease the counter by one; if the counter is zero, blocks until the counter is greater than zero. down() is analogous to wait().

 up(sem): increments the counter; wakes up one waiting process. up() is analogous to sig- nal().

Semaphores in computer science were introduced by the Dutch computer scientist Edsger Dijkstra, and so down() is sometimes called P(), from the Dutch for proberen, roughly "try [to decrement]", and up() is sometimes called V(), from the Dutch for verhogen, roughly "increment". Notice that we can use semaphores to impose both mutual exclusion and ordering constraints. In some sense, semaphores, with two operations, are more elegant than monitors, with ?ve operations (namely, lock(), unlock(), wait(), signal(), and broadcast()).

Some people, however, ?nd semaphores less intuitive thanmonitors. There is also an important difference between semaphores and signals: signals have no memory, whereas semaphores do have memory.

Posted Date: 3/12/2013 5:22:08 AM | Location : United States







Related Discussions:- Semaphores, Assignment Help, Ask Question on Semaphores, Get Answer, Expert's Help, Semaphores Discussions

Write discussion on Semaphores
Your posts are moderated
Related Questions
Problem: a) The CPU can access 2 storage devices directly. What are these 2 storage devices? b) Define 2 key issues involved in memory management. c) How do processes sha

When you run a program on your UNIX system, the system prepares a special environment for that program. This environment owns everything needed for the system to execute the progra

Explain the Sleep (ms) Function  This call places the current thread in a suspended state for the number of milliseconds passed as the parameter (ms). After that Windows NT wil

What is paging? Paging is a memory management scheme that authorizes the physical-address space of a process to be noncontiguous. Paging evades the considerable problem of fi

Explain the Fork Function Fork function causes a new process to be created. The calling progress is duplicated as an exact copy (called the child process) that differs only in

Write an application that does the following:(1) fill an array with 50 random integers; (2) loop through the array, displaying each value, and count the number of negative values;

Two Level Directory This kind of structure overcomes the problems of assigning unique names to the files. Thus there need not be any confusion among users. In this kind of s

Q. Why is it important to scale up system bus and device speeds as the CPU speed increases? Answer: Consider a system which carries out 50% I/O and 50% computes. Doubling-up

Question: (a) Red Hat Linux is distributed under the Open Source agreement. Explain what you understand by Open Source distribution system. (b) Write a short note on the L

Major page fault: If the page is not loaded in memory at the time the fault is stated, then it is named major or hard page fault. The handler in the machine requires to search a