卷別
計算機結構與作業系統(B)
選擇國立臺灣大學 2022 · 考試 · 第 7 題
考科計算機組織與結構
(5 pts) Consider the RISC-V code below were executed concurrently on two cores.
[x2] = 1
[x3] = 1
ld x1, 0(x2)
addi x1, x1, 1
sd x1, 0(x2)
ld x4, 0(x3)
add x4, x1, x4
sd x4, 0(x3)
Memory is shared by the two cores. Before executing the code, assuming registers x2 and x3 of each of the cores contain different values ( and ). The same register x2 and x3 of the two cores respectively contain the same value ( and ). The memory location x2 and x3 each contains the integer value 1 before executing the code. Assuming no instruction reordering is possible. What are all the possible values of x2 and x3 after code execution has completed?
- (A)x2 = 2, x3 = 3 or 4 or 5
- (B)x2 = 2 or 3, x3 = 3 or 4 or 5 or 6
- (C)x2 = 2 or 3, x3 = 3 or 4 or 5 or 6 or 7
- (D)x2 = 1 or 2 or 3, x3 = 2 or 3 or 4 or 5
- (E)x2 = 3, x3 = 4 or 5 or 6 or 7