Series: Subject: Topic:
Question: 47 of 222


Describe how a Semaphore is used in Operating System?
Asked by: tereraiterence | Member Since Jan-2009 | Asked on: Jan 26th, 2009

View all questions by tereraiterence

Showing Answers 1 - 8 of 8 Answers

Answered On : Mar 8th, 2009

View all answers by ankscorek

Semaphores provide mutual exclusion. They are used for process sync and are used to resolve deadlock conditions.
They are used in pairs basically wait() and signal().Commonly used semaphore is mutex()

Yes  2 Users have rated as useful.
Login to rate this answer.

Semaphore is a "process synchronization tool" which are assigned by two operation a. wait (p)b. signal (v)It states that if there are many proceess sharing a same variable, then other process must wait it until the process in critical section is completed, as the process in critical section is completed its send a signal to the other process to enter a critical section.

Login to rate this answer.

Semaphore provides a synchronous access to a shared resource. If multiple threads can access a hared resource concurrently, we need a mechanism that can prevent other threads to access the resource while one of the thread is using the resource. Any thread that needs an access to the resource must acquire the semaphore. If the semaphore is busy, it will be blocked/sleep. When the thread that is using the resource is done, it issues wakeup to the blocked threads.

Login to rate this answer.

Semaphores are variables used for the synchronization.

Yes  1 User has rated as useful.
Login to rate this answer.

Semaphore is a abstract datatype and monitor is a  programming construct...although both performs the function of mutual inclusion using monitor is sometimes safer than using semaphores because  in monitor functions related to the resources are placed in a single place and in semaphore the functions are distributed and less structured...there is a fear of order of calling the functions i.e wait and signal of semaphore..if the order goes wrong the deadlock condition may arise but in case of monitor it is more safe because the related function are structured in a single block..

Login to rate this answer.

Answered On : Jul 21st, 2012

A semaphore is a synchronization tool that provides a general-purpose solution for controlling access to critical sections.
A semaphore is an abstract data type (ADT) that defines a nonnegative integer variable which, apart from initialization, is accessed only through two standard operations: wait and signal.

Login to rate this answer.

Answered On : Feb 7th, 2013

View all answers by user569

Semaphore is a shared binary variable which can take values either 0 or 1. The primary purpose of them is to ensure mutual exclusion property between or among the two or more processes that want to enter into access the shared code, formally called as "Critical Section". Its necessary because if two processes are allowed to execute the same section of code simultaneously, then if they update same variable in the code at same time, conflicts will occur in the result of that process. So one process must be allowed to enter into the critical section. The two operations that can be performed on semaphore variables are: P(S) and V(s). P(s) checks if the value of semaphore variable S is less than 0, if so, then makes the process to wait in the loop. V(S) process increments the value of Semaphore. Whenever the process completes the execution of the critical section, it sets the value of semaphore to 1. The waiting process finds the value now 1, now its allowed to enter the critical section and execute its code.

Yes  1 User has rated as useful.
Login to rate this answer.

Semaphore is an non-negative integer, which is used to provide mutual exclusion to processes trying to access a same resource.

For example, if you are copying a file, then you cannot move it to some other folder. This is achieved by the copying process, which acquires a lock on that file. This does not allow any other process to access that file/resource.

Semaphores are used to prevent deadlock conditions, where 2 or more process keep on waiting for some event to happen, but that event may never happen.

Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions



twitter fb Linkedin GPlus RSS


Question Categories

Shell Scripting Interview Questions

Solaris Admin Interview Questions

UNIX Interview Questions

Unix Programming Interview Questions

Windows Interview Questions

Interview Question

 Ask Interview Question?


Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.