What exactly is a critical section?

后端 未结 3 1701
伪装坚强ぢ
伪装坚强ぢ 2021-01-18 03:06

Just want a little clarity on the this. Imagine I use the windows api of EnterCriticalSection. I call all of them with EnterCriticalSection(&criticalsection);

3条回答
  •  情话喂你
    2021-01-18 03:45

    Critical section is a code chunk. If any thread entered it, no other thread can enter until it's free. If 1 and 2 are different critical sections (i.e. handled by a different semaphore), someone can enter 2 if 1 is occupied.

提交回复
热议问题