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 ?

Explain time-sharing environment, In a multiprogramming and time-sharing en...

In a multiprogramming and time-sharing environment, several users share the system simultaneously. This situation can result in various security problems. a

What is a multiprocessing system, What is a multiprocessing system? Mul...

What is a multiprocessing system? Multiprocessor systems are those systems that use additional than a single processor for program execution. It is done for raising the executi

Race condition, list the prevention of mechanism for race condition with op...

list the prevention of mechanism for race condition with operating system

Nested Macro calls, . Nested Macro calls are expanded using the

. Nested Macro calls are expanded using the

Operating system, What criteria are important in choosing a file organisati...

What criteria are important in choosing a file organisation?

Explain the exit (status) function, Explain the Exit (status) Function  ...

Explain the Exit (status) Function  Exit function causes the calling process to be terminated. Actually, all file descriptors are immediately closed but the process is   not

Multi-level page tables, Multi-level page tables are tree-like structures t...

Multi-level page tables are tree-like structures to hold page tables. As an example, consider a two- level page table, again on a 32-bit architecture with 212 = 4 kbyte pages. Now,

Explainoptimal page replacement in detail, Optimal page replacement An...

Optimal page replacement An optimal page replacement algorithm has the least page fault rate of all algorithms. The algorithm states that put back the page that will not be us

Explain deadlock prevention, Deadlock Prevention Prevention is the name...

Deadlock Prevention Prevention is the name given to method that guarantee that deadlocks can never happen for the reason that the way the system is structured. Since 4 conditio

What is the use of fork and exec system calls, What is the use of fork and ...

What is the use of fork and exec system calls? Fork is a system call by which a latest process is created. Exec is also a system call, which is used after a fork by one of the

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