Semaphores, Operating System

Assignment Help:

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.


Related Discussions:- Semaphores

Define implementation of segmentation with an example, IMPLEMENTATION OF SE...

IMPLEMENTATION OF SEGMENTATION WITH AN EXAMPLE Segmentation is a memory-management scheme that represents the user view of memory. A logical address space is the collection of

Elimination of common sub expression - code optimizatin, Elimination of com...

Elimination of common sub expression during code optimization An optimizing transformation is a rule for rewriting a section of a program to enhance its execution efficiency wi

Explain many-to-one model (green threads), Many-to-One Model (Green Threads...

Many-to-One Model (Green Threads) Implementations of the many-to-one model a lot of user threads to one kernel thread permit the application to create any number of threads tha

Define process swapping , Swapping : Whole process is moved from the swap...

Swapping : Whole process is moved from the swap machine to the main memory for execution. Process size must be equal or less than to the used main memory. It is easier to exe

Cpu, what is cpu

what is cpu

Fundamental of operating system, An operating system provides the environme...

An operating system provides the environment within that programs are executed. Internally operating systems differ greatly in their makeup because they are organized along many di

What are the advantages and disadvantages of multithreading, What are the a...

What are the advantages and disadvantages of multithreading?  Advantages : Since by multithreading multiple executions are carried out in the same process environment t

Briefly explain about file system implementation, Briefly explain about fil...

Briefly explain about file system implementation? Several on-disk and in-memory structures are used to execute a file system. On disk, the file system may have information abou

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd