CMU: Semaphores

Check out my understanding of semaphores, please!

I understand the idea of ​​counting semaphores and binary semaphores. However, the difference between spin-lock and semaphore is implemented using signal () and the form of wait () for me.

For example, a spin lock has basically two values ​​(binary true / false to lock or unlock). So spinlock is basically a binary semaphore, right?

Any process trying to enter a critical section while another process is inside will be unable while it is locked, and it will rotate and constantly check the lock status until it is unlocked, and then it can enter and lock it. .

A semaphore that uses the signal () and wait () functions significantly adds or subtracts a value from a variable. There is a limitation on the critical section. It will be open only if the variable has some value. An example implementation for a consumer process will wait (full), and then when it is full, and at the end it will signal (empty). While the producer process can wait (empty) and execute when true is empty, then when it finishes it, the signal is (complete).

What is the difference between wait () and a spinlock that essentially “waits” in a loop?

+3
source share

Source: https://habr.com/ru/post/1763398/


All Articles