某个计算会生成两个数组a和b,使得0≤i 以下哪一项表示ExitX和EntryY的正确实现? (一种) (B) (C) (D) (A) A 参见http://quiz.geeksforgeeks.org/operating-systems-process-management-question-13/Process X: Process Y:
private i; private i;
for (i=0; i < n; i++) { for (i=0; i < n; i++) {
a[i] = f(i); EntryY(R, S);
ExitX(R, S); b[i]=g(a[i]);
} }
ExitX(R, S) {
P(R);
V(S);
}
EntryY (R, S) {
P(S);
V(R);
}
ExitX(R, S) {
V(R);
V(S);
}
EntryY(R, S) {
P(R);
P(S);
}
ExitX(R, S) {
P(S);
V(R);
}
EntryY(R, S) {
V(S);
P(R);
}
ExitX(R, S) {
V(R);
P(S);
}
EntryY(R, S) {
V(S);
P(R);
}
(B) B
(C) C
(D) D答案: (C)
解释: The purpose here is neither the deadlock should occur
nor the binary semaphores be assigned value greater
than one.
A leads to deadlock
B can increase value of semaphores b/w 1 to n
D may increase the value of semaphore R and S to
2 in some cases
这个问题的测验