信号量和关键区域之间有什么区别?

use*_*745 3 semaphore

我唯一理解的是

  • 信号量是一种原始的方式
  • 关键区域有一个GUARD变量(信号量也可以,但名称不是GUARD!)

??

那么差异呢?

Don*_*Ray 5

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.