卷別
計算機結構與作業系統
選擇國立臺灣大學 2026 · 考試 · 第 6 題
考科作業系統
Regarding synchronization, and are two processes sharing the critical section with the following assumptions:
- The "load" and "store" machine-language instructions are atomic.
- The two processes share
turnto indicate whose turn.
Given the following two approaches (code shown for process ; exchange and for ):
Approach 1 for Process :
while (true) {
turn = i;
while (turn == j)
;
/* critical section */
turn = j;
/* remainder section */
}
Approach 2 for Process :
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.