← 回題庫

卷別

計算機結構與作業系統

選擇

國立臺灣大學 2026 · 考試 · 第 6 題

Regarding synchronization, PiP_i and PjP_j are two processes sharing the critical section with the following assumptions:

  • The "load" and "store" machine-language instructions are atomic.
  • The two processes share turn to indicate whose turn.

Given the following two approaches (code shown for process PiP_i; exchange ii and jj for PjP_j):

Approach 1 for Process PiP_i:

while (true) {
    turn = i;
    while (turn == j)
        ;
    /* critical section */
    turn = j;
    /* remainder section */
}

Approach 2 for Process PiP_i:

while (true) {
    while (turn == j)
        ;
    /* critical section */
    turn = j;
    /* remainder section */
}

Select correct description(s).

  • (A)
    Approach 1 satisfies the requirement of mutual exclusion.
  • (B)
    Approach 1 satisfies the requirement of bounded waiting.
  • (C)
    Approach 2 satisfies the requirement of mutual exclusion.
  • (D)
    Approach 2 satisfies the requirement of progress.
  • (E)
    Approach 2 satisfies the requirement of bounded waiting.

標準解析

AI 已複查