【发布时间】:2015-04-02 02:11:52
【问题描述】:
我正在研究 Linux 中的信号量。我想知道信号量值是否可以超过初始化值?如果是这样,什么时候会发生?
例如,信号量值被初始化为 1。 如果我使用 up(sem) 连续增加两次,信号量的值是否会增加超过 1。
x(void){
sema_init(sem1, 1);
down(sem1);
{
.
. // some code implementation
.
}
up(sem1); // i understand this increment the value back to 1.
up(sem1);
/* what exactly does this statement do to the semaphore?
Will it increment the value to 2? If so what is the meaning of this statement? */
}
【问题讨论】:
标签: linux multithreading linux-kernel linux-device-driver semaphore