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 ?

Graph - plotting job, This exercise uses a graph-plotting program ( gnuplot...

This exercise uses a graph-plotting program ( gnuplot ) to convert tabular data into an image. This is a technique that is very widely used to visualize scientific data; with app

What are the typical elements of a process image, What are the typical elem...

What are the typical elements of a process image? User data: Modifiable part of user space. May have program data, user stack area, and programs that might be modified. User

Explain lru additional reference bits algorithm, Additional Reference bits...

Additional Reference bits algorithm Here we keep an 8-bit byte for every page in memory. At standard intervals the reference bit is shifted by the OS. If a shift register conta

Explain relative file organization, Relative file organization A rela...

Relative file organization A relative file is an array of fixed-length slots and the records can be inserted in the first free slot found from the beginning of the file and

What is the purpose of the global catalog, Question: (a) i. Consider A...

Question: (a) i. Consider Active Directory as a database, then for each type and new class of objects, what is created? ii. What is the purpose of the global catalog? ii

What is contiguous allocation, What is contiguous allocation? Allocati...

What is contiguous allocation? Allocation of a group of consecutive sectors for a one file.

Explain about error detection method, Q. Explain about Error detection meth...

Q. Explain about Error detection method? Error detection: error can occur in CPU, in I/O devices or in memory hardware. Operating system constantly needs to be aware of possi

Explain formal language grammar, Explain Formal Language Grammar A form...

Explain Formal Language Grammar A formal language grammar is a set of formation rules which explain which strings formed from the alphabet of a formal language are syntacticall

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