操作系统之信号量代码填空题!!!
原子操作:
P:
down(s) {
S--;
if (s>0) {
place this process in s.queue;
block this process;
}
}
V:
up(s) {
s++;
if (s<=0) {
remove a process from s.queue;
place the process on ready list;
}
}
课本基础:
1.独木桥问题(west------bridge------east)
严格轮流,西先行:
Semaphore S1=1,S2=0;
Void WTE (void) {
while(TRUE) {
down(&s1);
pass( );
up(&s2);
}
}
Void ETW (void){
while(TRUE) {
down(&s2);
pass( );
up(&s1);
}
}
2.生产者、消费者问题(The producer-consumer problem )

3.读者、写者问题(The readers and writers problem)


课外考点:








