操作系統(tǒng)之信號量代碼填空題?。?!
原子操作:
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.生產(chǎn)者、消費者問題(The producer-consumer problem )

3.讀者、寫者問題(The readers and writers problem)


課外考點:









標簽: