What is the difference between a semaphore and a critical region?

The only thing I realized is

  • Semaphore - a primitive way
  • the critical area has a GUARD variable (the semaphore also does, but the name is not GUARD!)

??

so what's the difference?

+3
source share
4 answers

Typically, a critical area is a place where, if there were two separate threads of execution, there would be a race condition or some other undesirable effect. Semaphores are one way to prevent two threads from being in a critical area at the same time.

+5
source

GUARD 1 , n ( n) .

+2

, ( ), , (CS) ( ) - , ,

+1

" ":

  • , undefined, .

  • , , . . " ". Intel / CLI/STI.

0
source

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


All Articles