AdminDev Labs

Semaphore vs Mutex vs Admindev: Fight!

Informações:

Synopsis

## Semaphore vs Mutex vs AdminDev ### Semaphore - More of a signal than a lock/unlock - Integer value accessed through wait() and signal() - wait() checks if the int is less than or equal to 0, decrements value - signal() increments the integer value ### Semaphore Over Mutex - Mutex locks can have busy waiting. - Semaphore wait() results in busy waiting, but a process can block itself with a wakeup() implementation - Semaphore can still result in syncing issues - Critical-Section: Two processes can be in the same section if the wait() and signal() sequence is not monitored ### Semaphores in OS Dev - Counting semaphore - Value can range dramatically - Control access to a given resource consisting of finite instances - Semaphore is initialized to the given number of resources - Each process that wants to use a resource performs wait() (lowering the value count) - signal() is called when a process is finished utilizing a resource (increasing the value count) - When count == 0, all resources are used - Processe