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 ?

Is there any way to execute truly stable storage, Q. Is there any way to ex...

Q. Is there any way to execute truly stable storage? Describe your answer. Answer: Truly steady storage would never lose data. The fundamental technique for steady storage is

What is the sequence in which resources may be utilized, What is the sequen...

What is the sequence in which resources may be utilized? Under normal mode of operation, a process may utilize a resource in the following sequence: Request: If the requ

Binary and data representation, Computing uses three number bases:- Binary ...

Computing uses three number bases:- Binary (base 2), Octal (base 8) and Hexadecimal (base 16). Binary has been described before, although various catchphrases are used to describe

What is an operating system?, What is an operating system? An operating...

What is an operating system? An operating system is a program that acts as a mediator between a user and the computer hardware. The function of an operating system is to provid

Deadlock resoloution technique, justify the role played by the operating sy...

justify the role played by the operating system in managing the process to avoid deadlock

Linux, Discuss the risks of having a single root user

Discuss the risks of having a single root user

Compare user threads and kernel threads, Compare user threads and kernel th...

Compare user threads and kernel threads. User threads:- User threads are supported above the kernel and are executed by a thread library at the user level. Thread creation

Array-initialization loops using lru replacement algorithm, Q. Consider th...

Q. Consider the two-dimensional array A: int A[][] = new int[100][100]; Whereas A [0][0] is at location 200 in a paged memory system with pages of size 200. A little process

Define the scheduling in multitasking, Define the Scheduling in Multitaskin...

Define the Scheduling in Multitasking Earlier we learned the concepts and advantages of multitasking. In a system in which one or more tasks( threads or processes) attempt to s

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