Answer Posted / sagarika mishra
In computer science, a semaphore is a protected variable or
abstract data type which constitutes the classic method for
restricting access to shared resources such as shared
memory in a multiprogramming environment. A counting
semaphore is a counter for a set of available resources,
rather than a locked/unlocked flag of a single resource. It
was invented by Edsger Dijkstra. Semaphores are the classic
solution to preventing race conditions in the dining
philosophers problem, although they do not prevent resource
deadlocks.
Semaphores can only be accessed using the following
operations. Those marked atomic should not be interrupted
(that is, if the system decides that the "turn is up" for
the program doing this, it shouldn't stop it in the middle
of those instructions) for the reasons explained below.
P(Semaphore s) // Acquire Resource
{
wait until s > 0, then s := s-1;
/* must be atomic because of race conditions */
}
V(Semaphore s) // Release Resource
{
s := s+1; /* must be atomic */
}
Init(Semaphore s, Integer v)
{
s := v;
}
| Is This Answer Correct ? | 29 Yes | 12 No |
Post New Answer View All Answers
How do I clean up my computer to make it run faster?
How many goroutines are in a core?
Can a laptop have both ssd and hdd?
Explain about memory management in operating system.
Can I factory reset my laptop without a recovery disc?
What is a file in computer terms?
How many bytes we can send to apple push notification server in iOS operating system?
What are Odm Commands.
Which one is the first operating system?
What os is used at google?
How do I compare plugins in notepad ++?
How To Convert A Normal Vg To Big & Scalable Vg And Also Big To Scalable Vg?
Is microsoft coming out with a new operating system?
What is the shortcut key to refresh laptop?
How do I combine multiple folders on a mac?