tags:

views:

27

answers:

2

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?

+1  A: 

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.

DonaldRay
+1  A: 

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.

Chris O