两个进程共享信号量s,
一旦其中一个进程执行了semwait(s),它将得到信号量--》进入临界区,使s减1;
(To receive a signal via semaphore s,a Process executes the primitive semwait(s))
而第二个进程被阻止进入临界区,因为当它试图执行semwait(s)时,s 为 0,它会被挂起以等待第一个进程离开临界区并执行semsignal(s)(释放信号量s)
(To transmit a signal via semaphore s, a process executes the primitive semsignal(s))
这个时候第二个进程可以恢复执行。
three operations are defined:
A Semaphore may be initialized to a nonnegative integer value;
the Semawait operation decrements the semaphore value. If the value becomes negative ,then the process executing the semWait is blocked.Otherweise,the process continues execution;
The SemSingal operation increments the semaphore value.If the resuling value is less than or equal to zero,then a process blocked by a semWait operation,if any,is unblocked.
没有评论:
发表评论