Please look at the code:
Code:
for(i = 0; i < 100; i++) {
mutex_lock();
...
mutex_unlock();
}
If a process A into the critical region 100 times, at this time, process B also into the critical region, now the B will be sleep until the A execute 100 times loop.
If I use the semaphore instead of the mutex_lock, it will never happen, the B will get the semaphore when the A isn't execute 100 times loop.
Does this the mutex feature??
Can anybody tell me, why it is??