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
Will disk cleanup delete my files?
When I startup my computer the screen is black?
How do I merge folders on mac?
describe the situation in which priority inversion can occur
Why is my computer so slow?
How do I compare files in notepad ++?
Can I factory reset my laptop without a recovery disc?
What is the best free operating system?
What is the difference between concurrency and parallelism?
Is i3 good for gaming?
How do you clear cache on a laptop?
what are latest technologies ? and how will keep yourself up to date ?
Is kernel a os?
Give some examples of use of thread in a single user multiprocessing system
windows 3.1 is