Semaphore
Semaphore is a simply a variable. This variable is used to solve critical section problem and to achieve process synchronization in the multi processing environment. The two most common kinds of semaphores are counting semaphores and binary semaphores. Counting semaphore can take non-negative integer values and Binary semaphore can take the value 0 & 1. only. Semaphore have below API functions wait(S s) { while(s <= 0) ; s--; } signal(S s) { s++; } init(S, A) { S = A; } Below are some problems to understand how it works. 1. Design multiple readers or 1 writer at a time 2. Dog and Master Problem: Master initialise N food in bucket. Only one Dog at a time can get the food. When food get empty, Dog notify to Master. When get notified, master put +N food when food get empty and food should not overflow. Only one Master/Dog can access the resource at a time. //Inicialize Semaphores init(D, 1) //Sem...