操作系统|流程管理|问题6

某个计算生成两个数组A和b,使得A[i]=f(i)为0≤ 对于0,i

null
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和EntryY的正确实现?

(A)

ExitX(R, S) {
  P(R);
  V(S);
}

EntryY (R, S) {
  P(S);
  V(R);
}

(B)

ExitX(R, S) {
  V(R);
  V(S);
}

EntryY(R, S) {
  P(R);
  P(S);
}

(C)

ExitX(R, S) {
  P(S);
  V(R);
}
EntryY(R, S) {
  V(S);
  P(R);
}

(D)

ExitX(R, S) {
  V(R);
  P(S);
}
EntryY(R, S) {
  V(S);
  P(R);
}

(A) A. (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

这个问题的小测验

© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享