Explain briefly the working of semaphore with example ?, Operating System

Assignment Help:

Explain briefly the working of semaphore with example ?

The E.W. Dijkstra (1965) abstracted the key idea of mutual exclusion in his concepts of semaphores.

Definition
A semaphore is a confined variable whose value is able to be accessed and altered only by the operations P and V and initialization operation called as 'Semaphoiinitislize'.

Binary Semaphores is able to assume only the value 0 or the value 1 counting semaphores as well called general semaphores can assume only nonnegative values.

The P or sleep or wait or down operation on semaphores S written as P(S) or wait (S) operates as follows:

P(S):  IF  S > 0
                THEN S:= S-1
                 ELSE   (wait on S)

The V or wakeup or signal or up operation on semaphore S written as V(S) or signal (S) operates as follows:

V(S)   IF (one or more process is waiting on S)
                THEN (let one of these processes proceeds)
                ELSE   S: = S +1

Operations P and V are complete as indivisible, single, atomic action. It is guaranteed that formerly a semaphore operation has stared, no other process are able to access the semaphore until operation has completed. The Mutual exclusion on the semaphore S is enforced within P(S) and V(S).

If several processes attempt a P(S) concurrently only process will be allowed to proceed. The other processes will be set aside waiting however the implementation of P and V guarantees that processes will not suffer indefinite postponement.

Semaphores resolve the lost-wakeup problem.


Related Discussions:- Explain briefly the working of semaphore with example ?

Networking tidbits, There is a very small amount of networking background r...

There is a very small amount of networking background required for Project 2. In Project 2, we want our computer (or our "host") to request information over the Internet from a rem

Explain the network protocols, Explain the Network protocols There are ...

Explain the Network protocols There are a wide variety of network protocols to choose from traditionally client - server developers were required to choose a communications pro

What is external fragmentation?, What is external fragmentation? As pro...

What is external fragmentation? As process are removed from and loaded to the memory free memory space is bracken into pieces .external fragmentation take place when enough mem

What are the different types of semaphore?, What are the different types of...

What are the different types of semaphore? Principally the semaphore is able to be classified into two on the basis of their values a)      Counting semaphore: In counting s

Describe the purpose of the open and close operations, Q. Describe the pur...

Q. Describe the purpose of the open() and close() operations. Answer: The open() operation notifies the system that the named file is about to become active. The c

Define page fault, Page fault is a trap to the software gained by the har...

Page fault is a trap to the software gained by the hardware when a process accesses a page that is goes in the virtual address space, but not added in physical memory. In the har

Write a short note on disk structure, Write a short note on disk structure ...

Write a short note on disk structure Modern disk drives are initiate as large one dimensional array of logical blocks where the logical block is the smallest unit of transfer.

Custom memory allocation, Some people write custom memory allocators to mee...

Some people write custom memory allocators to meet their speci?c needs. Although this is not needed for most of the applications, it is also not uncommon. The goal, of course, is t

Write pseudo code to implement the pthread create wrapper, Write pseudo cod...

Write pseudo code to implement the pthread_create wrapper of the Tern memoizer. Note you need to describe your data structure for maintaining deterministic thread IDs. In addition,

Explain file control list and user control list, Q. Researchers have recom...

Q. Researchers have recommended that instead of having an access list associated with each file (specifying which users can access the file and how) we should have a user control

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