开发者

Semaphores in operating system

开发者 https://www.devze.com 2023-04-09 07:35 出处:网络
Well, what exactly changes the context of processes. Say i have a algo, in which say S=0开发者_如何转开发;

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

精彩评论

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

关注公众号