edited by
7,836 views
22 votes
22 votes
Semaphore operations are atomic because they are implemented within the OS _________.
edited by

1 Answer

Best answer
28 votes
28 votes
The concept of semaphores is used for synchronization.
Semaphore is an integer with a difference. Well, actually a few differences.
You set the value of the integer when you create it, but can never access the value directly after that; you must use one of the semaphore functions to adjust it, and you cannot ask for the current value.
There are semaphore functions to increment or decrement the value of the integer by one.
Decrementing is a (possibly) blocking function. If the resulting semaphore value is negative, the calling thread or process is blocked, and cannot continue until some other thread or process increments it.
Incrementing the semaphore when it is negative causes one (and only one) of the threads blocked by this semaphore to become unblocked and runnable.

Therefore, all semaphore operations are atomic. Implemented in kernel,
selected by

Related questions

33 votes
33 votes
1 answer
1
makhdoom ghaya asked Nov 18, 2016
5,714 views
The highest-response ratio next scheduling policy favours ___________ jobs, but it also limits the waiting time of _________ jobs.
23 votes
23 votes
1 answer
2
makhdoom ghaya asked Nov 18, 2016
5,811 views
Under paged memory management scheme, simple lock and key memory protection arrangement may still be required if the _________ processors do not have address mapping hard...
12 votes
12 votes
4 answers
3
17 votes
17 votes
2 answers
4
makhdoom ghaya asked Nov 27, 2016
4,508 views
The condition for overflow in the addition of two $2's$ complement numbers in terms of the carry generated by the two most significant bits is ___________.