【发布时间】:2020-12-10 20:49:44
【问题描述】:
这是我的代码:
wait(){
while(S<=0)
//puts the thread in the block list until it wakes up(by calling post)
S = S-1
}
信号量的等待函数中有while循环,不能简单的用if语句吗?
【问题讨论】:
-
if不是循环语句,只是条件检查 -
if只检查一次,while重复检查。 -
但是为什么要反复检查呢,一次检查不够?
标签: c linux linux-kernel semaphore