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);
All happens atomically i.e. wrap pre and post protocols.


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