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
BENEFITS OF THREADS OVER PROCESS If implemented correctly after those threads have some advantages of (multi) processes, they take: 1. Less time to create a new thread tha

Under what circumstances do page faults occur?  Describe the actions taken by the operating system when a page fault occurs. A page fault happens when an access to a page that

A file system depends on data structures about the files, beside the file structure. The former is named metadata-data that defines data. Each file is accumulated with an inode, wh

What are conditions under which a deadlock situation may arise? A deadlock situation can arise if the following four conditions hold simultaneously in a system: a. Mutual ex

Hashed page table method A general approach for managing address spaces larger than 32 bits is to use a hashed page table with the hash values being the virtual-page number.

Differentiate tightly coupled systems and loosely coupled systems? Loosely coupled systems:-  Every processor has its own local memory  Every processor can communicate

What are privileged instructions? Some of the machine instructions that may cause harm to a system are designated as privileged instructions. The hardware permits the privilege

Explain the Statements Present in Assembly Language An assembly program consists of subsequent three types of statements: a. Imperative statements: this point out an action

Q. Explain about Deadlocks? Deadlocks for (int i = 0; i // first find a thread that can finish for (int j = 0; j if (!finish[j]) { boolean temp = true; for

Define the properties of Interactive operating system Interactive:- This system is composed of many short transactions where the results of the next transaction may be unpred