开发者

Semaphores in operating system

Well, what exactly changes the context of processes. Say i have a algo, in which say

S=0开发者_如何转开发;
begin
signal(S);
<critical>
wait(S);
end

Now in this, when my signal is executed, will the process be preempted and the process from the queue will be executed?


I think what you want to do this

S=0;
begin
wait(S);    
<critical>
signal(S);
end

First wait for some signal(locking, or signal from some other process) and then enter into the critical section. And once out of the critical section, signal the other waiting processes to wake up.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜