What is a semaphore? Explain busy waiting semaphores.


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 parallel programming environment.

 
Weak, Busy-wait Semaphores:
The simplest way to implement semaphores.
Useful when critical sections last for a short time, or we have lots of CPUs.
S initialized to positive value (to allow someone in at the beginning).
S is an integer variable that, apart from initialization, can only be accessed through 2
atomic and mutually exclusive operations: wait(s):
                              while (s.value != 0);
                              s.value--;
                        signal(s):
s.value++;
All happens atomically i.e. wrap pre and post protocols.

0 comments:

Feel free to contact the admin for any suggestions and help.