the only thing i understood is
- semaphore is a primitive way
- critical region has a GUARD variable (semaphore also does but the name is not GUARD!)
??
so whats the difference?
the only thing i understood is
??
so whats the difference?
Generally, a critical region is a place where, if two separate threads of execution were to be present, a race condition or some other undesirable effect would occur. Semaphores are one way of preventing two threads from being in the critical region at the same point in time.
The GUARD would only allow 1 thread to enter the critical region at a time, whereas the semaphore can allow n threads (you specify n) to concurrently enter the critical region.