111 年 國立臺灣大學醫療器材與醫學影像研究所《計算機結構與作業系統(B)》
第 1 題5 分
【單選題】:只有一個選項為正確答案。不倒扣。
Multiple Choices: only one among the four or five choices is the correct
answer. No penalty for incorrect answer.
- (5 pts) Given the logical address of a memory and its page tables where the
page size is 4 bytes, the number of entries on each page is 4, and the size
of physical memory is 32 bytes. Please provide the physical address of
variable "g" and "o" shown in below figure.
🖼️【此處有附圖,請對照原卷】
(A) 26 and 10
(B) 26 and 7
(C) 22 and 10
(D) 10 and 26
(E) 7 and 10
登入後即可作答並保存紀錄。
核心觀念
分頁式記憶體管理會把邏輯位址拆成「邏輯頁號」與「頁內位移」。頁表將邏輯頁號轉成實體頁框號,頁內位移則保持不變:
解題方法
圖中變數 位於邏輯位址 ,變數 位於邏輯位址 ;頁表顯示邏輯頁 對應實體頁框 ,邏輯頁 對應實體頁框 。頁面大小為 bytes,因此位址除以 的商是頁號,餘數是頁內位移。
對 :
所以 位於邏輯頁 、頁內位移 。邏輯頁 對應實體頁框 ,因此:
對 :
所以 位於邏輯頁 、頁內位移 。邏輯頁 對應實體頁框 ,因此:
第 2 題5 分
【單選題】:只有一個選項為正確答案。不倒扣。
Multiple Choices: only one among the four or five choices is the correct
answer. No penalty for incorrect answer.
2. (5 pts) Please provide the page offset and the size of page table according
to the following parameters. Consider a system with a 24-bit logical address,
each entry is 1 byte, and each page is 4 KiB.
(A) 9 and 32 KiB
(B) 10 and 16 KiB
(C) 11 and 8 KiB
(D) 12 and 4 KiB
(E) 13 and 1 KiB
登入後即可作答並保存紀錄。
核心觀念
本題考驗作業系統(Operating System)中**分頁記憶體管理(Paging Memory Management)**的邏輯位址結構與頁表(Page Table)大小計算。
在分頁機制下,一個長度為 位元的邏輯位址(Logical Address)包含兩個部分:
- 頁號(Page Number, ):用於索引頁表,高位元部分佔 位元。
- 頁偏移量(Page Offset, ):用於指定頁面內的具體位元組位置,低位元部分佔 位元。
關鍵公式與關係如下:
- 頁面大小(Page Size, ):與頁偏移量 的關係為 。
- 總頁數(Number of Pages, ):由頁號位元數 決定,。
- 頁表大小(Page Table Size):一級頁表包含所有頁面的映射項目,公式為:
解題方法
根據題目給定的參數:
- 邏輯位址長度
- 頁面大小
- 單一頁表項目大小
步驟推導如下:
1. 計算頁偏移量(Page Offset)
頁面大小 。
因為 ,可得頁偏移量位元數 為:
2. 計算頁號位元數(Page Number Bits)與總頁數
頁號位元數 。
因此,系統的總頁數 為:
3. 計算頁表大小(Page Table Size)
將總頁數乘以單一頁表項目的大小:
由上述計算可知,頁偏移量為 12,頁表大小為 4 KiB。
選項分析
- (A) 9 and 32 KiB:錯誤。
第 3 題5 分
【單選題】:只有一個選項為正確答案。不倒扣。
Multiple Choices: only one among the four or five choices is the correct
answer. No penalty for incorrect answer.
3. (5 pts) The following line opens a file for write only.
int fd = open(file_name, O_CREAT | O_EXCL | O_WRONLY,
new_file_mode);
if (fd == -1) {
/* Handle Error */
}
Please indicate the sequence of executing the above line if fd is equal to -1,
using the symbol in the circle.
🖼️【此處有附圖,請對照原卷】
(A) A - B - C -> D
(B) E -> B
(C) A -> D
(D) A -> E
(E) B -> C -> A
登入後即可作答並保存紀錄。
核心觀念
open() 成功時回傳非負的檔案描述符;失敗時回傳 -1,並設定 errno。O_CREAT | O_EXCL 表示建立新檔案且要求檔名尚未存在;O_WRONLY 表示以只寫方式開啟。若檔案已存在,這組旗標會使呼叫失敗,但 fd == -1 本身不能指出具體失敗原因。
解題方法
圖中左側是 user space,中間是 kernel memory,右側是 secondary storage,並標出目錄結構與 file control block 等資訊。開檔要求由 A 進入核心處理;D 是核心將結果送回使用者程式的路徑,E 則位於存取磁碟目錄結構的路徑。
open() 失敗時,核心回傳 -1,程式接著判斷 fd == -1,因此依圖中的失敗返回路徑為 A → D。檔名已存在只是 O_EXCL 下的一種失敗原因;權限不足、路徑錯誤或系統資源不足也會使 open() 失敗,需查看 errno 才能辨別。
第 4 題5 分
【單選題】:只有一個選項為正確答案。不倒扣。
Multiple Choices: only one among the four or five choices is the correct
answer. No penalty for incorrect answer.
4. (5 pts) Compilers could affect program execution efficiency. We have two
compiler options, C1 and C2. Given a program A, compiler C1 results in a
dynamic instruction count of 1.0x 109 and has an execution time of 1.1
second, while compiler C2 results in a dynamic instruction count of 1.2 x 109
and an execution time of 1.5 second. Assume the processor has a clock
cycle time of 1ns. What is the average CPI for that program compiled with
C1 and C2, respectively?
(A) C1= 1.3; C2=1.35
(B) C1= 1.2; C2=1.30
(C) C1= 1.1; C2=1.25
(D) C1= 1.0; C2=1.20
(E) None of the above
登入後即可作答並保存紀錄。
核心觀念
本題考查計算機結構中的核心效能方程式(CPU Performance Equation)。
計算機執行程式所需的 CPU 執行時間()由三個關鍵因子決定:
- 動態指令數(Dynamic Instruction Count, ):程式執行過程中所實際執行的總指令數,主要由軟體演算法與編譯器(Compiler)決定。
- 平均每指令時脈週期數(Cycles Per Instruction, ):執行每條指令平均需要的時脈週期數,由處理器微架構設計(Microarchitecture)與編譯器的指令選用策略決定。
- 時脈週期時間(Clock Cycle Time, ):處理器一個時脈週期的時間長度,單位為秒(s),由硬體製程與電路時脈頻率決定。
其基本關係式如下:
經移項後,求算平均 的公式為:
解題方法
1. 條件整理與單位轉換:
- 處理器時脈週期時間:
- 編譯器 C1:
- 動態指令數:
- 執行時間:
- 編譯器 C2:
- 動態指令數:
- 執行時間:
2. 計算 C1 的平均 CPI:
將 C1 的數據代入 公式:
3. 計算 C2 的平均 CPI:
將 C2 的數據代入 公式:
第 5 題5 分
【單選題】:只有一個選項為正確答案。不倒扣。
Multiple Choices: only one among the four or five choices is the correct
answer. No penalty for incorrect answer.
5. (5 pts) Consider the fragment of RISC-V assembly codes below:
#1
sd x29, 12(x16)
#2
ld x29, 8(x16)
#3
sub x17, x29, x14
#4
add x15, x17, x14
#5
sub x15, x30, x14
Assume that we have a standard 5-stage pipeline (IF, ID, EX, MEM,
WB) without data forwarding, and a register can be written and read back
in the same cycle without introducing a hazard. Which CPU cycles do
instruction #3 and instruction #4 complete assuming a perfect cache?
(A)7;9
(B) 8;9
(C) 8; 10
(D) 9; 11
(E) 9; 12
登入後即可作答並保存紀錄。
核心觀念
- 5 階段管線(5-stage Pipeline):標準管線包含 IF(取指)、ID(解碼/讀取暫存器)、EX(執行/計算位址)、MEM(記憶體存取)、WB(寫回暫存器)共 5 個階段。
- 無資料轉發下的資料冒險(Data Hazard without Forwarding):當後續指令(Consumer)需要用到前續指令(Producer)寫入的暫存器資料時,在無 Data Forwarding 的機制下,Consumer 的 ID 階段必須 Stall,直到 Producer 完成 WB 階段將數據寫回暫存器。
- 同週期讀寫暫存器(Split-cycle Register Access):題目設定「a register can be written and read back in the same cycle」,代表暫存器檔案(Register File)採「前半週期寫入(WB)、後半週期讀取(ID)」的時脈邊緣設計。因此 Producer 的 WB 階段與 Consumer 的 ID 階段可以在「同一個 CPU 週期」並行。
解題方法
1. 指令 #1:sd x29, 12(x16)
- 無任何 Hazard,於 Cycle 1 開始順暢執行:
- Cycle 1: IF
- Cycle 2: ID
- Cycle 3: EX
- Cycle 4: MEM
- Cycle 5: WB
- 完成週期:Cycle 5。
2. 指令 #2:ld x29, 8(x16)
- 指令 #1 在 Cycle 2 讀取
x29,指令 #2 在 Cycle 6 寫入x29,兩者為 WAR(Write After Read)關係。在 Standard In-order Pipeline 中,WAR 不會引發 Hazard。 - 緊接在指令 #1 後進入管線:
- Cycle 2: IF
- Cycle 3: ID
- Cycle 4: EX
- Cycle 5: MEM
- Cycle 6: WB
- 完成週期:Cycle 6(於 Cycle 6 前半週期將數據寫入暫存器
x29)。
3. 指令 #3:sub x17, x29, x14
- 存在 RAW(Read After Write)Hazard:指令 #3 需要讀取由指令 #2 寫入的
x29。 - 由於無 Forwarding 且支援同週期讀寫,指令 #3 的 ID 階段必須等到指令 #2 的 WB 階段(Cycle 6)才能成功讀取
x29:- Cycle 3: IF
- Cycle 4~5: ID(Stall,等待指令 #2 完成 MEM 並進入 WB)
- Cycle 6: ID(於 Cycle 6 後半週期完成讀取
x29) - Cycle 7: EX
- Cycle 8: MEM
- Cycle 9: WB
- 完成週期:Cycle 9。
4. 指令 #4:add x15, x17, x14
- 存在 RAW Hazard:指令 #4 需要讀取由指令 #3 寫入的
x17。 - 指令 #4 的 ID 階段必須等到指令 #3 的 WB 階段(Cycle 9)才能成功讀取
x17:- Cycle 4: IF
第 6 題5 分
【單選題】:只有一個選項為正確答案。不倒扣。
Multiple Choices: only one among the four or five choices is the correct
answer. No penalty for incorrect answer.
6. (5 pts) Below is the RISC-V assembly program generated for the body of
function f: "int f(int a, int b, int c)". The program follows RISC-V's convention
and uses registers x10-x18 to pass parameters and return values in function
calls.
addi x2, x2, -16
sd
x1, 0(x2)
slli
x5, x12, 5
sd
x5, 8(x2)
jal
x1, m
ld
x11, 8(x2)
lui
x12, 0x11232
addi x12, 0x334
Id
x1, 0(x2)
addi x2, x2, 16
jal
x0, g
Which of the following is the respective C code? Note that the addi
instruction in RISC-V is sign-extended for immediate values.
(A) return g(m(a, b5), 0x11232334)
(B) return g(m(a, b), c32, 0x33411232)
(C) return g(m(a, b), 0x11232334, c32)
(D) return g(m(a, c), b32, 0x11232334)
(E) return g(m(a, b), c*32, 0x11232334)
登入後即可作答並保存紀錄。
核心觀念
本題考查 RISC-V 架構下的呼叫慣例(Calling Convention)、暫存器傳參規則、立即數編碼與構造,以及尾端呼叫優化(Tail Call Optimization)。
-
RISC-V 暫存器角色與呼叫慣例:
$x2$(sp):堆疊指標(Stack Pointer)。$x1$(ra):傳回地址暫存器(Return Address)。$x10$–$x17$(a0–a7):函式參數傳遞與回傳值暫存器。其中$x10$(a0)代表第 1 個參數與回傳值,$x11$(a1)代表第 2 個參數,$x12$(a2)代表第 3 個參數。- 根據題目
int f(int a, int b, int c)的定義:進入函式 時,傳入參數 分別存放於$x10$, $x11$, $x12$中。
-
算術與立即數指令:
slli rd, rs1, shamt:邏輯左移指令。位移 位元相當於乘以 。lui rd, imm(Load Upper Immediate):將 20 位元立即數載入至暫存器的最高 20 位元(bits 31–12)。addi rd, rs1, imm:將 12 位元符號延伸(sign-extended)立即數加至暫存器。配合lui可構造完整的 32 位元常數。
-
尾端呼叫優化(Tail Call Optimization):
- 在函式結束前直接還原堆疊與
$x1$(ra),並以jal x0, g(跳轉且不儲存傳回地址)轉移控制權給函式 ,相當於 C 語言中的return g(...)。
- 在函式結束前直接還原堆疊與
解題方法
將 RISC-V 組合語言程式碼逐行推導並與 C 語言邏輯進行比對:
關鍵程式碼逐行推導
第 7 題5 分
【單選題】:只有一個選項為正確答案。不倒扣。
Multiple Choices: only one among the four or five choices is the correct
answer. No penalty for incorrect answer.
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 the executing the code,
assuming registers x2 and x3 of each of the cores contain different values
(X2coreo != x3core0 and x2core1!= x3core1). The same register x2 and x3 of the
two cores respectively contain the same value (x2core = x2core1 and x3core0
= x3core1). 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
登入後即可作答並保存紀錄。
核心觀念
本題考查多處理器/多核心系統中的共用記憶體與並行執行(Shared Memory Concurrent Execution)、競態條件(Race Condition)以及資料覆蓋更新失誤(Lost Update Problem)。
關鍵核心概念如下:
- 暫存器私有性與記憶體共用性:Core 0 與 Core 1 各自擁有獨立的暫存器檔案(私有暫存器 與 ),但暫存器 與 所指向的記憶體位址 與 為兩核心共享。
- 指令執行順序限制(Program Order):題目明確指出「無指令重排(No instruction reordering is possible)」,因此單一核心內部的指令嚴格遵守程式順序執行,但兩核心之間的指令交錯(Interleaving)順序為任意。
- 競態與資料覆蓋:若兩核心同時讀取同一記憶體位址的初始值,計算後各自寫回,較晚寫回者的結果會覆蓋較早寫回者,導致一次更新失誤。
解題方法
令 Core 0 為 ,Core 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)(將 寫回 )
步驟一:分析記憶體位址 的可能最終值與暫存器 的數值
-
競爭覆蓋(Lost Update):
若 與 皆在任何核心執行 之前發生,兩核心皆讀到 。
經 加 1 後, 且 。
兩核心陸續執行 寫回 ,最終記憶體狀態 。
此時暫存器組合為 。 -
序列化執行(Serial Execution):
若其中一核心(例如 )先完整執行完 ,將 更新為 ;隨後另一核心()才執行 。- ,且經 寫回後 。
- 讀取到更新後的 ,經 計算後得到 ,最後經 寫回。
- 最終記憶體狀態 。
此時暫存器組合為 或 。
-
矛盾與不可達狀態驗證:
檢驗 是否可能成立:- 欲使 ,必須 讀取到 寫入的 ,即偏序關係 。
- 欲使 ,必須 讀取到 寫入的 ,即偏序關係 。
- 單核心內部程式順序要求 與 。
- 若兩者同時成立,將導出偏序環:
此為時間邏輯上的矛盾。因此, 與 絕不可能同時為 。
第 8 題4 分
【複選題】:至少有一個選項為正確答案。每一個選項分別計分。錯誤選項為零分,
不倒扣。
Multiple Choices with one or more correct answers: at least one among
the four or five choices are the correct answer. Each answer will be
graded individually. No penalty for incorrect selection.
8. (4 pts) The UNIX system call wait() returns the process identifier of a
terminated child process. Select correct description(s).
(A) Cascading termination means that "if a process terminates, then all
its children must also be terminated."
(B) The process identifier of a zombie process is released even if its
parent has not yet invoked wait().
(C) If there is no child process when wait() is invoked, then it is as if no
wait() is there.
(D) If there is an orphan process, the system can assign a process as
the new parent which periodically invokes wait().
登入後即可作答並保存紀錄。
核心觀念
本題考查 UNIX 作業系統的行程管理(Process Management)、行程生命週期以及 wait() 系統呼叫的核心觀念,主要涵蓋以下重點:
- 連鎖終止(Cascading Termination):作業系統環境中,當父行程終止時,強制將其創建的所有子行程一併終止的機制。
- 殭屍行程(Zombie Process):子行程已終止,但父行程尚未調用
wait()收集其離開狀態碼(Exit Status),導致該行程在行程表(Process Table)中的條目與行程識別碼(PID)仍被保留的狀態。 - 孤兒行程(Orphan Process):父行程先於子行程終止,導致子行程失去父行程。作業系統會將孤兒行程重新指定父行程(Reparenting,通常為
init行程,),由新父行程負責在其終止時調用wait()回收資源。 wait()系統呼叫的邊界行為:wait()用於將父行程阻塞(Block),直到任一子行程終止。若調用時呼叫者完全沒有子行程,wait()會立即回傳失敗狀態碼 ,並將errno設定為ECHILD。
解題方法
依據 POSIX 標準規範與經典作業系統教科書(如 Silberschatz Operating System Concepts)對行程控制與 wait() 系統呼叫的定義,針對各選項進行觀念比對與邏輯推導:
選項分析
-
(A) 正確
- 分析:連鎖終止(Cascading Termination)的標準定義即為:「若一個行程終止(無論是正常結束或異常終止),則其所產生的所有子行程也必須隨之終止。」在不允許子行程獨立於父行程之外生存的系統設計中,作業系統會主動觸發此機制。
-
(B) 錯誤
- 分析:當子行程執行完畢終止後,會進入「殭屍狀態(Zombie State)」。此時該行程的記憶體與程式碼雖已被釋放,但其行程識別碼(PID)與行程表(Process Table)條目依然保留在系統中。
第 9 題4 分
【複選題】:至少有一個選項為正確答案。每一個選項分別計分。錯誤選項為零分,
不倒扣。
Multiple Choices with one or more correct answers: at least one among
the four or five choices are the correct answer. Each answer will be
graded individually. No penalty for incorrect selection.
9. (4 pts) Regarding threads, select correct description(s).
(A) Implicit threading transfers the creation and management of
threading from application developers to compilers and run-time
libraries.
(B) Thread pools limit the number of threads that exist at any time,
which is advantageous to resource-constrained systems.
(C) A system with a single computing core cannot support concurrent
computation.
(D) POSIX thread (Pthread) cancellation occurs only when a thread
reaches a cancellation point, which is an asynchronous cancellation.
登入後即可作答並保存紀錄。
核心觀念
本題考查作業系統中「執行緒(Thread)」的相關觀念,包含:
- 隱式執行緒 (Implicit Threading) 的定義與實現方式。
- 執行緒池 (Thread Pool) 的優勢與資源管理。
- 並行 (Concurrency) 與 平行 (Parallelism) 的本質差異及單核心系統的能力。
- POSIX Thread (Pthread) 取消機制 (Thread Cancellation) 的兩種模式:異步取消 (Asynchronous Cancellation) 與延遲取消 (Deferred Cancellation)。
解題方法
依據經典作業系統權威教材(Silberschatz - Operating System Concepts)對執行緒特性的定義進行逐一比對與判讀:
- 隱式執行緒:將執行緒的建立與管理責任由應用程式開發者轉移至編譯器與執行期函式庫 (Runtime Libraries),如 OpenMP、Grand Central Dispatch (GCD) 等。
- 執行緒池:限制系統中同時存活的執行緒總數上限,避免因無限制建立執行緒而耗盡記憶體或引發過度的 Context Switch。
- 並行 vs 平行:並行 (Concurrency) 指多個任務在重疊的時間段內交替進行(單核心排程即可達成);平行 (Parallelism) 指多個任務在同一個時間點同時執行(必須具備多處理核心)。
- 執行緒取消機制:目標執行緒僅在到達「取消點 (Cancellation Point)」時才執行終止動作的機制稱為延遲取消 (Deferred Cancellation);而異步取消 (Asynchronous Cancellation) 則會立即終止目標執行緒。
選項分析
- (A) 正確。
根據隱式執行緒 (Implicit Threading) 的定義,隨著多核心系統普及,手動編寫與維護多執行緒程式(如手動呼叫 Pthread API)會大幅增加開發複雜度與出錯率。隱式執行緒機制將執行緒的建立、指派與排程管理轉交由編譯器與執行期函式庫(例如 OpenMP、Java Fork-Join 框架等)自動處理,開發者僅需定義平行執行的任務。
第 10 題4 分
【複選題】:至少有一個選項為正確答案。每一個選項分別計分。錯誤選項為零分,
不倒扣。
Multiple Choices with one or more correct answers: at least one among
the four or five choices are the correct answer. Each answer will be
graded individually. No penalty for incorrect selection.
10. (4 pts) Given a set of 3 periodic processes as shown below:
Process
P1
P2
P3
Arrival Time
0
10
20
Period
30
70
100
Burst Time
10
10
20
Perform the rate-monotonic scheduling. Select correct description(s).
(A) The worst-case turnaround time (from the arrival time to the time of
the completion of a process) of P2 is 10.
(B) The worst-case turnaround time of P3 is 30.
(C) If we increase the burst time of P3 by X time units, the worst-case
turnaround time of P3 will also be increased by X time units.
(D) If we change the arrival time of a process, the worst-case
turnaround times of all processes will be the same.
登入後即可作答並保存紀錄。
核心觀念
- 比率單調排程 (Rate-Monotonic Scheduling, RMS):
- 一種適用於週期性行程 (Periodic Processes) 的搶佔式靜態優先權排程演算法 (Preemptive Fixed-Priority Scheduling)。
- 優先權指派規則:行程的週期 越短,其優先權越高。
- 最壞情況周轉時間 (Worst-Case Turnaround Time / Response Time):
- 行程從「到達 (Arrival)」到「執行完成 (Completion)」所需的時間稱為周轉時間 (Turnaround Time)。
- 臨界瞬間定理 (Critical Instant Theorem):在靜態優先權排程中,當一個行程與所有比它優先權更高的行程同時到達時,該行程會遭遇最長延遲,此時算出的周轉時間即為該行程的最壞情況周轉時間 ()。
- 響應時間分析 (Response Time Analysis, RTA):
對於行程 ,其最壞情況周轉時間 可透過以下遞迴公式(迭代法)求解:
其中 代表優先權高於 的所有行程集合, 為 的執行時間 (Burst Time), 為高優先權行程的週期。
解題方法
1. 確定各行程的優先權順序
根據 RMS 規則「週期 越短,優先權越高」:
- :週期 最高優先權 (Priority 1)
- :週期 中優先權 (Priority 2)
- :週期 最低優先權 (Priority 3)
優先權大小關係為:。
2. 計算各行程的最壞情況周轉時間 ()
-
行程 :
為最高優先權行程,不會被任何行程搶佔。
-
行程 :
高優先權行程僅有 ()。帶入 RTA 遞迴公式:
使用迭代法求解:- 設定初始值
- 第一輪迭代:
- 第二輪迭代:(收斂)
得 的最壞情況周轉時間 。
驗算題目給定到達時間:當 時,(到達於 )與 (到達於 )同時到達,觸發臨界瞬間:
- : 執行(耗時 10)
- : 執行(耗時 10)
於 完成,周轉時間為 。
-
行程 :
高優先權行程有 與 。帶入 RTA 遞迴公式:
使用迭代法求解:- 設定初始值
第 11 題5 分
【複選題】:至少有一個選項為正確答案。每一個選項分別計分。錯誤選項為零分,
不倒扣。
Multiple Choices with one or more correct answers: at least one among
the four or five choices are the correct answer. Each answer will be
graded individually. No penalty for incorrect selection.
11. (5 pts) Which of the following are correct for Virtual Memory?
(A) Each process has its own virtual space
(B) Allow more processes to run concurrently
(C) Allow address spaces to be shared by several processes
(D) Use SEVERAL bases
(E) Use ONE base
登入後即可作答並保存紀錄。
核心觀念
本題考查作業系統中**虛擬記憶體(Virtual Memory)**的核心機制、設計目的與硬體支援架構。虛擬記憶體的主要目標與特性包括:
- 位址空間隔離(Memory Protection & Isolation):系統為每一個行程(Process)提供獨立且連續的虛擬位址空間,防止行程間互相干擾。
- 提高多道程式設計度(Degree of Multiprogramming):結合需求分頁(Demand Paging),行程不必全部載入實體記憶體即可開始執行,從而提高系統併發(Concurrency)執行的行程數量。
- 記憶體共享(Memory Sharing):透過頁表將不同行程的虛擬頁面映射到同一個實體頁框,達成共享函式庫(Shared Libraries)與共享記憶體(Shared Memory)。
- 非連續記憶體定址(Non-contiguous Allocation):位址轉換機制(MMU)利用多個頁面/區段基底位址(Base Addresses)進行動態重定位,而非單一的基底暫存器(Base Register)。
解題方法
從作業系統對虛擬記憶體的實現機制切入分析:
- 行程位址空間管理:虛擬記憶體將邏輯位址與實體位址解耦,每一行程皆視自己擁有專屬的記憶體空間。
- 需求載入與併發性:未使用的頁面可保留在次級儲存裝置(如硬碟/SSD 的 Swap space),節省實體記憶體空間,容納更多行程同時運行。
- 映射彈性:虛擬位址轉換為實體位址時,可靈活映射至相同的實體頁框達成共享。
- 位址轉換硬體(MMU):分頁系統(Paging)使用頁表(Page Table),每一頁表項(PTE)或每一段(Segment)都含有對應實體空間的基底位址(Base),且多行程切換時會使用不同的頁表基底暫存器(PTBR),故採用多基底機制。
選項分析
-
(A) Each process has its own virtual space:正確。
虛擬記憶體為每個行程提供獨立的虛擬位址空間(Virtual Address Space)。行程內所使用的記憶體位址均為邏輯位址,由作業系統與記憶體管理單元(MMU)透過頁表轉換至實體記憶體,確保行程間的記憶體保護與獨立性。 -
(B) Allow more processes to run concurrently:正確。
第 12 題5 分
【複選題】:至少有一個選項為正確答案。每一個選項分別計分。錯誤選項為零分,
不倒扣。
Multiple Choices with one or more correct answers: at least one among
the four or five choices are the correct answer. Each answer will be
graded individually. No penalty for incorrect selection.
12. (5 pts) Which of the following are correct for consistency semantics for file
systems?
(A) Consistent semantic specify when the ownership of a lock will be
transferred to another process.
(B) Consistent semantics specify when modification of data by one
process will be observable by other processes.
(C) UNIX semantic is supported by modern distributed file systems.
(D) Session semantic requires one file to be associated with a single
physical image that is accessed as an exclusive resource.
(E) Consistent semantic specify how multiple processes of a system are
to access a shared file.
登入後即可作答並保存紀錄。
核心觀念
本題考查作業系統中檔案系統的**一致性語意(Consistency Semantics)**及其在單機與分散式檔案系統中的實現特性。
- 一致性語意(Consistency Semantics)的定義:
定義多個行程(Processes)或使用者同時存取同一個共享檔案時的存取規則,特別規範某一行程修改檔案資料後,該變更在何時能夠被其他行程觀察到(Observable)。 - 常見的一致性語意模型:
- UNIX 語意(UNIX Semantics):行程對已開啟檔案所做的寫入變更會立即對其他所有開啟該檔案的行程可見。此外,行程間可共享檔案指標(File Pointer)。
- 會話語意(Session Semantics):行程在開啟(Open)至關閉(Close)檔案期間所做的修改,僅存取於該 Session 的局部快取複本中。必須等到檔案被關閉後,變更才會對之後開啟檔案的新 Session 可見;已處於開啟狀態的 Session 無法觀察到該變更。
- 不可變共享檔案語意(Immutable-Shared-Files Semantics):一旦檔案被宣告為共享,該檔案即變為唯讀(Read-only),無法再被任何行程修改。
解題方法
本題切入點為檢驗作業系統經典理論(如 Silberschatz 所著 Operating System Concepts)對 Consistency Semantics 的定義與特性分類:
- 區分 consistency semantics 與 synchronization 的範疇:一致性語意關注資料可見性時機與存取模型,而非鎖(Lock)擁有權的移轉。
- 檢驗一致性語意通用定義:確立 Consistency Semantics 規範的是多行程如何存取共享檔案以及資料修改何時可被觀察。
- 分析分散式檔案系統(DFS)的折衷設計:UNIX 語意要求極高的一致性成本,在現代分散式檔案系統中因網路延遲與快取同步問題難以有效維持,通常改用 Session 語意或弱一致性模型。
選項分析
第 13 題5 分
【複選題】:至少有一個選項為正確答案。每一個選項分別計分。錯誤選項為零分,
不倒扣。
Multiple Choices with one or more correct answers: at least one among
the four or five choices are the correct answer. Each answer will be
graded individually. No penalty for incorrect selection.
13. (5 pts) Regarding the critical-section problem and synchronization, select
correct description(s).
(A) A resource-allocation graph has a cycle if and only if there is a
deadlock.
(B) The "progress" requirement implies the "bounded waiting"
requirement.
(C) The "bounded waiting" requirement implies the "progress"
requirement.
(D) The "freedom from deadlock" property implies the "freedom from
starvation" property.
(E) The "freedom from starvation" property implies the "freedom from
deadlock" property.
登入後即可作答並保存紀錄。
核心觀念
本題考驗作業系統中**臨界區段問題(Critical-Section Problem, CSP)**的三大要求、**資源分配圖(Resource-Allocation Graph, RAG)的死鎖條件,以及死鎖(Deadlock)與飢餓(Starvation)**之間的邏輯推導關係。
-
臨界區段問題的三大必要條件:
- 互斥(Mutual Exclusion):若有行程在臨界區段中執行,則其他行程皆不可進入其臨界區段。
- 進行(Progress):若無行程在臨界區段中執行,且有行程欲進入臨界區段,則僅有「不在剩餘區段(Remainder Section)的行程」可參與決定下一個進入者,且此選擇不可無限期推遲(即系統整體必須持續推進,無死鎖)。
- 有限等待(Bounded Waiting):自某行程提出進入請求後,到該請求獲准前,其他行程獲准進入臨界區段的次數必須有上限(即個別行程不會被無限期擱置,無飢餓)。
-
死鎖(Deadlock)與飢餓(Starvation)的定義與關係:
- 死鎖(Deadlock):一組行程互相等待對方持有的資源,導致集合內所有行程皆無法繼續推進(系統整體卡死)。
- 飢餓(Starvation / Indefinite Blocking):個別行程被無限期推遲獲得資源,但系統中其他行程仍可持續獲得資源並推進。
- 邏輯包含關係:「無飢餓(Freedom from Starvation)」是比「無死鎖(Freedom from Deadlock)」更強的條件。若系統無飢餓,代表所有行程最終皆可獲得資源,故必定不會發生死鎖。
解題方法
解答此類同步與死鎖的觀念選擇題,應從**極限反例(Counterexample)與集合邏輯(Set Logic)**切入:
- 資源分配圖:區分「單一實體(Single Instance)」與「多個實體(Multiple Instances)」。
- Progress vs. Bounded Waiting:Progress 關心「系統整體(System-level)」,Bounded Waiting 關心「個別行程(Process-level)」。
- Deadlock vs. Starvation:Deadlock 是「全體無法推進」,Starvation 是「個體被不公平對待」。利用包含關係:。
選項分析
- (A) A resource-allocation graph has a cycle if and only if there is a deadlock.(錯誤)
- 分析:資源分配圖(RAG)中存在環(Cycle)與死鎖(Deadlock)的「充要條件(if and only if)」關係僅在每種資源皆只有單一實體(Single Instance)時成立。若資源包含多個實體(Multiple Instances),則「有環」僅為發生死鎖的必要條件而非充分條件。例如:當圖中有環,但持有用資源的行程中存在不等待任何資源的其他行程時,該行程執行完畢釋放資源後即可打破環,因此有環不一定會死鎖。題目未限定單一實體,故此敘述錯誤。
第 14 題5 分
【單選題】:只有一個選項為正確答案。不倒扣。
Multiple Choices: only one among the four or five choices is the correct
answer. No penalty for incorrect answer.
14.(5 pts) Assume a virtual memory system with an 4KiB page size. The
cache capacity is 16KiB, and the block size is 8-word (1 word = 4 bytes).
Which cache architecture could be implemented as a virtually-indexed,
physically tagged cache:
(A) Direct-mapped cache
(B) 2-way associative cache
(C) 4-way associative cache
(D) 8-way associative cache
(E) 16-way associative cache
登入後即可作答並保存紀錄。
核心觀念
本題考驗虛擬記憶體(Virtual Memory)與快取記憶體(Cache)結合時的 VIPT (Virtually-Indexed, Physically-Tagged) 架構設計限制,以及如何避免重名問題(Aliasing / Synonym Problem)。
-
VIPT 的工作原理與優點:
VIPT 允許 CPU 在利用虛擬位址(Virtual Address, VA)進行快取索引(Index)搜尋的同時,平行向 TLB 查詢物理頁號(Physical Page Number, PPN)。當 TLB 翻譯出 PPN 後,再與快取中讀出的物理標籤(Physical Tag, PT)進行比對。此舉能大幅降低快取的存取延遲(Latency)。 -
避免 Aliasing 的黃金法則:
由於頁面翻譯過程中,虛擬位址與物理位址的頁內偏移量(Page Offset)完全相同(即 ),若要保證 VIPT 在硬體上不會產生 Aliasing 問題,快取 Index 與 Block Offset 所需的位元數,必須完全落在 Page Offset 的範圍內。定理公式表示如下:
等價於單路容量(Way Capacity)不得大於頁面大小(Page Size):
解題方法
步驟一:計算 Page Offset 位元數與 Block Offset 位元數
-
頁面大小(Page Size):
-
區塊大小(Block Size):
步驟二:建立組關聯度 與快取索引位元的關係
- 快取總容量(Cache Capacity):
- 設快取為 -way 組關聯(Set-Associative),則 Set 數量為:
步驟三:代入 VIPT 不產生 Aliasing 的不等式
亦可直接由單路容量(Way Capacity)判斷:
計算結果顯示:組關聯度 必須至少為 4-way,快取的 Index 位元才不會侵入虛擬頁號(VPN)的位元範圍,從而能無縫實現為 VIPT 架構。
第 15 題5 分
【複選題】:至少有一個選項為正確答案。每一個選項分別計分。錯誤選項為零分,
不倒扣。
Multiple Choices with one or more correct answers: at least one among
the four or five choices are the correct answer. Each answer will be
graded individually. No penalty for incorrect selection.
15. (5 pts) Assume the CPI for INT instructions, FP instructions, L/S instructions,
and branch instructions for a given processor P is 1, 2, 4, and 2, respectively.
Consider a program F that includes 12 x 106 INT instructions, 15 x 106 FP
instructions, 50 x 106 L/S instructions, and 13 x 106 branch instructions.
Assume the program executes on a machine with a single processor P that
has a 3.2 GHz clock rate. Which of the following are correct?
(A) If one can optimize the program F by removing 80% of the INT
instructions, the execution time of F can be reduced by more than
3%.
(B) It is possible to make program F run 2 times faster by reducing the
CPI of the FP instructions.
(C) One can optimize program F to run more than 2 times faster by
reducing the CPI of the L/S instructions to 1.2.
(D) Suppose a new type of INT instruction called INT1 is added to the
instruction set of processor P to replace the existing INT instructions.
On average, through the use of the new INT instruction, we can
reduce the number of INT instructions needed to execute a program
by 50%, while increasing the clock cycle time by only 10%. If we
replace the INT instructions in program F with the INT1 instructions,
program F will run faster on processor P.
(E) If 30 x 106 system call instructions (each has CPI of 10) are added
to the program F, F will run more than 2 times slower after the
addition.
登入後即可作答並保存紀錄。
核心觀念
本題核心在於評估計算機系統的效能,主要涵蓋以下三大觀念與公式:
-
CPU 效能方程式(CPU Performance Equation):
程式的執行時間 決定於指令總數(Instruction Count, )、平均每指令週期數(Cycles Per Instruction, )以及時脈週期時間(Clock Cycle Time, )的三者乘積:
其中 為時脈頻率(Clock Rate),且 。 -
總週期數計算:
當程式包含多種不同類型的指令時,總執行週期數為各式指令週期數之累加:
-
阿姆達爾定律(Amdahl's Law)與加速比(Speedup):
加速比定義為改進前與改進後的執行時間比值:
若時脈週期時間不變(),則加速比僅取決於總週期數之比值。
解題方法
首先計算出程式 在未經任何修改前的基準總週期數()與基準執行時間():
- INT 指令週期數: 週期
- FP 指令週期數: 週期
- L/S 指令週期數: 週期
- Branch 指令週期數: 週期
將各類別週期數相加,得到原始總週期數:
原始執行時間為:
接著針對各選項的改動條件,計算新的總週期數與新的執行時間,並進行比較。
選項分析
-
(A) 正確
- 推導與計算:
若減少 的 INT 指令,則減少的 INT 指令數為 。
因 INT 的 ,故減少的週期數為:
執行時間降低的比率為:
- 結論:,執行時間減少超過 ,故選項 (A) 正確。
- 推導與計算:
-
(B) 錯誤
- 推導與計算:
若要使程式 執行速度提升 倍(),新的總週期數必須縮減為原本的一半:
然而,FP 指令所佔用的總週期數僅為 週期。即便將 FP 指令的 CPI 降低至 (極限優化情況),所能減少的最大週期數也只有 週期,優化後的極限總週期數仍有:
理論最大加速比僅為 倍(即僅能加快約 ),遠低於 倍。 - 結論:根據阿姆達爾定律,單純優化 FP 指令不可能使程式達到 倍加速,故選項 (B) 錯誤。
- 推導與計算:
第 16 題5 分
【複選題】:至少有一個選項為正確答案。每一個選項分別計分。錯誤選項為零分,
不倒扣。
Multiple Choices with one or more correct answers: at least one among
the four or five choices are the correct answer. Each answer will be
graded individually. No penalty for incorrect selection.
16. (5 pts) Recent hardware architectural extensions include the support for
Trusted Execution Environment (TEE). Hardware isolates the software
running in the TEE from the outside attackers. Intel provides the hardware
support called Software Guard Extensions (SGX) that allows programs to
run in its TEE called enclave in userspace. Intel SGX encrypts the enclave's
code and data in CPU registers and RAM memory. Attackers that control
another application or privileged systems software such as an operating
system can only read or write encrypted code and data of the enclave.
Which of the following are true?
(A) Intel SGX ensures that the software running in the TEE can never
crash.
(B) As the OS kernel is involved when loading the application's binary
into the enclave, Intel SGX supports remote attestation to
authenticate the binary to ensure the application's safety.
(C) It is possible to run an entire OS kernel such as Linux in the SGX
enclave.
(D) Although the enclave is encrypted by the Intel SGX hardware, an
attacker residing in the OS kernel could still modify the enclave's
page tables to affect the enclave's execution.
(E) To support encrypting the enclave's secrets for persistent storage,
the SGX enclave could use a persistent hardware-based encryption
key to securely encrypt and store its sensitive data in a way that
ensures the data can be retrieved only when the trusted
environment is restored.
登入後即可作答並保存紀錄。
核心觀念
本題考查 Intel SGX (Software Guard Extensions) 的硬體架構、信任模型(Threat Model)、保護機制與常見攻擊面。重點觀念包含:
- 信任執行環境 (Trusted Execution Environment, TEE) 與 Enclave:
Intel SGX 允許應用程式在使用者空間(User Space)開闢一個受硬體保護隔離的受信任區域,稱為 Enclave。 - SGX 的威脅模型(Threat Model):
SGX 假設底層的作業系統 Kernel、Hypervisor,甚至其他擁有最高權限的特權軟體與外部攻擊者皆不可信(Untrusted Host)。即使 Kernel 被惡意軟體控制,也無法直接讀取或修改 CPU 暫存器與 RAM 中 Enclave 的加密資料與程式碼。 - 執行權限限制:
Enclave 內部的程式碼固定運行於 CPU 的 Ring 3(User Privilege Level),無法執行任何 Ring 0 特權指令(如修改控制暫存器 、存取硬體 I/O、處理中斷等)。 - 頁表控制與記憶體保護:
Enclave 實體記憶體(Enclave Page Cache, EPC)在 RAM 中經過 Memory Encryption Engine (MEE) 進行透明加密與完整性驗證。然而,虛擬位址到實體位址的頁表(Page Tables)仍由不可信的 OS Kernel 維護與管理。 - 遠端認證 (Remote Attestation):
由於 Enclave 程式碼由不可信的 OS 載入,遠端第三方可以透過 SGX 硬體簽署的認證報告(Measurement,如MRENCLAVE/MRSIGNER),驗證 Enclave 是否正確載入且未遭竄改。 - 資料封印 (Data Sealing):
利用 Intel CPU 硬體內建的根金鑰(Root Key)透過EGETKEY指令衍生出專屬加密金鑰,將 Enclave 內部敏感資料加密後持久化儲存(Persistent Storage)至不可信的硬碟中。
解題方法
針對安全硬體架構複選題,應從「SGX 威脅模型」、「特權等級 (Ring Level)」、「硬體隔離邊界」與「密碼學服務(Attestation & Sealing)」四大面向審視各選項:
- 檢視軟體崩潰(Crash)與硬體安全邊界(Confidentiality & Integrity)的區別。
- 釐清 OS Kernel 在 SGX 中扮演的角色(載入器與頁表管理者)及其衍生的邊界威脅。
- 判定 Enclave 的權限等級(Ring 3)是否支援執行完整 OS Kernel。
- 驗證控制頁表(Page Tables)攻擊手法(如 Controlled-Channel Attack)之可行性。
- 確認持久化資料加密機制(Sealing)的運作原理。
選項分析
- (A) 錯誤:Intel SGX 提供的是**機密性(Confidentiality)與完整性(Integrity)**的硬體保護,無法防止軟體內部的程式碼
第 17 題5 分
【複選題】:至少有一個選項為正確答案。每一個選項分別計分。錯誤選項為零分,
不倒扣。
Multiple Choices with one or more correct answers: at least one among
the four or five choices are the correct answer. Each answer will be
graded individually. No penalty for incorrect selection.
17. (5 pts) Which of the following are true about RISC-V instructions about the
registers in the register file and instruction size?
(A) If the registers were halved, I-type instructions could have 2 more
immediate bits.
(B) If the registers were halved, there must be less I-type instructions.
(C) If the registers were halved, shift amounts would change to 0-63.
(D) Increasing the size of each bit field to support more registers
potentially makes each instruction longer.
(E) Increasing the number of registers must increase the code size of a
RISC-V assembly program.
登入後即可作答並保存紀錄。
核心觀念
本題旨在考驗對 RISC-V 指令集架構(ISA) 的指令格式(Instruction Formats)、暫存器檔案(Register File)編碼欄位分配、暫存器資料寬度(XLEN)與程式碼大小(Code Size)之間相互影響關係的理解。
-
暫存器索引位元數(Register Index Bits):
在包含 個通用暫存器的架構中,指定單一暫存器所需的欄位寬度為 位元。- 標準 RISC-V 32 位元架構(RV32I)擁有 32 個通用暫存器(),故每個暫存器欄位佔據 位元。
-
I-type 指令格式:
在標準 32 位元 RISC-V 指令中,I-type 指令結構配置如下:
I-type 指令共包含 2 個暫存器欄位:來源暫存器 與目的暫存器 。 -
移位範圍(Shift Amount,
shamt):
移位指令所需的移位位元數受限於暫存器資料位元寬度(XLEN)。對於 32 位元架構(),移位範圍為 (需 位元);對於 64 位元架構(),移位範圍才是 (需 位元)。 -
程式碼大小(Code Size)影響因素:
。
暫存器數量增加能有效降低 暫存器溢出(Register Spilling) 發生率,進而顯著減少記憶體載入與儲存指令(lw/sw)的數量。
解題方法
分析 RISC-V 各指令欄位之間的相互影響,著重於以下三個層面:
-
欄位變動與位元釋出計算:
若暫存器數量減半(由 32 個減至 16 個),單一暫存器欄位寬度將從 位元縮減為 位元,每個暫存器欄位可省下 位元。檢視特定指令格式內含有幾個暫存器欄位,即可計算出釋出的總位元數。 -
區分暫存器數量(Count)與暫存器資料寬度(Width):
暫存器數量影響的是「暫存器索引欄位()的寬度」;而移位範圍(shamt)則是由「暫存器的資料寬度(XLEN)」決定,兩者概念不可混淆。 -
分析 Register Spilling 對 Code Size 的權衡(Trade-off):
評估程式碼大小時,必須同時考慮「單一指令位元數」與「組譯後的指令總數量」。暫存器數量增加雖可能使暫存器欄位變大,但能大幅減少記憶體存取指令,因此整體 Code Size 的增減需視兩者權衡而定。
選項分析
- (A) 正確
- 原因:原 RV32 架構有 32 個暫存器,每個暫存器欄位需要 位元。若暫存器數量減半為 16 個,每個暫存器欄位僅需 位元。
第 18 題8 分
【單選題】:只有一個選項為正確答案。不倒扣。
Multiple Choices: only one among the four or five choices is the correct
answer. No penalty for incorrect answer.
18. (8 pts) Given a set of n processes, the arrival time of the i-th process is (i-
1), and the burst time of the i-th process is (2n-2i+2), as shown below:
Process
P1
P2
P3
Arrival Time
0
1
2
Burst Time
2n
2n-2
2n-4
Pn
n-1
2
Perform preemptive scheduling to minimize the average turnaround
time (from the arrival time to the time of the completion of a process) of all
processes. Assume that the minimized average turnaround time of all
processes is Wn³+Xn²+Yn+Z. Select correct description(s).
(A) W + X + Y + Z = 1.
(B) X - Y + Z = -1.
(C) 2XY = 1.
(D) W² + 3Z = 2.
登入後即可作答並保存紀錄。
核心觀念
-
最小化平均週轉時間(Minimum Average Turnaround Time)之排程策略:
在作業系統的 CPU 排程理論中,搶佔式最短剩餘時間優先(Shortest Remaining Time First, SRTF)(又稱 Preemptive Shortest Job First, Preemptive SJF)已被證明能達到理論上最小的平均等待時間與平均週轉時間。 -
週轉時間(Turnaround Time, )與平均週轉時間(Average Turnaround Time, )定義:
- 到達時間:
- CPU 執行時間(Burst Time):
- 完工時間(Completion Time):
- 個別進程週轉時間:
- 平均週轉時間:
-
常用級數求和公式:
- 一次方和:
- 二次方和:
解題方法
步驟一:分析 SRTF 搶佔行為與甘特圖狀態
觀察各進程在到達時刻的剩餘執行時間:
- 於 時, 到達,剩餘執行時間為 ,開始執行。
- 於 時, 已執行 個時間單位,剩餘時間變為 。此時 到達,其 Burst Time 為 。
由於 ,故 搶佔(Preempt) 的 CPU 執行權。 - 於 時, 已執行 個時間單位,剩餘時間變為 。此時 到達,其 Burst Time 為 。
由於 ,故 搶佔 。
一般化推導:在時間 時(),新進程 到達,其 Burst Time 為 。而前一個進程 剛執行了 個時間單位,剩餘時間為 。
因為 ,每一個新到達的進程 都會立即搶佔前一個進程。
此搶佔過程持續到 (即最後一個進程 到達)為止。
步驟二:計算各進程之完工時間(Completion Time, )
在 時, 到達,此後不再有新進程加入。此時各進程的剩餘執行時間如下:
- :
- :
- :
- : (對所有 )
- :
由於剩餘時間滿足 ,根據 SRTF 規則,CPU 將依照 的順序依次將各進程執行至完工:
-
的完工時間 :
於 開始連續執行 個單位時間:
-
的完工時間 :
於 完工後繼續執行剩餘的 個單位時間:
-
的完工時間 一般式:
對任意進程 ,其完工時間為:
令 ,當 從 變動至 時, 從 變動至 :
代回 可得:
第 19 題10 分
【複選題】:至少有一個選項為正確答案。每一個選項分別計分。錯誤選項為零分,
不倒扣。
Multiple Choices with one or more correct answers: at least one among
the four or five choices are the correct answer. Each answer will be
graded individually. No penalty for incorrect selection.
19.(10 pts) Which of the following statements are correct?
(A) ARM big.LITTLE is a multi-core architecture designed for energy-
efficiency.
(B) You are asked to deliver 90x speedup from a 100-processor system.
The target application can only have at most 5% of codes that can't
be serialized.
(C)A RISC processor can always deliver better performance than a
CISC processor.
(D) A larger block size could potentially lead to more false sharing
misses.
(E) A larger block size could potentially help reduce compulsory misses.
登入後即可作答並保存紀錄。
核心觀念
本題涵蓋計算機結構與平行處理的核心觀念,主要考點如下:
- 多核心與異質計算架構(Heterogeneous Architecture):ARM big.LITTLE 架構之設計目標與運作機制。
- 阿姆達爾定律(Amdahl's Law):平行處理系統中,加速比(Speedup)與不可平行化(串行)程式碼比例之間的定量關係:
其中 為串行程式碼比例, 為處理器數量。 - RISC 與 CISC 架構比較:指令集架構(ISA)對處理器效能(CPU Time = Instruction Count CPI Clock Cycle Time)的影響與邊界情況。
- 快取記憶體效能與偽共享(Cache Performance & False Sharing):快取區塊大小(Block size)對偽共享失效(False sharing miss)與強制失效(Compulsory miss / Cold miss)的影響。
解題方法
- 選項 (A):檢視 ARM big.LITTLE 之架構特性,確認其透過結合高效能核心與低功耗核心達到節能目的。
- 選項 (B):利用阿姆達爾定律公式,帶入處理器數量 及目標加速比 ,反求最大允許的串行程式碼比例 ,並與題目給予的 5% 進行對比。
- 選項 (C):由 CPU效能公式分析 RISC 與 CISC 的優缺點,確認「絕對(always)」一詞是否成立。
- 選項 (D) 與 (E):評估加大快取區塊(Block size)對空間局部性(Spatial locality)與快取一致性(Cache coherence / MESI 協定)的雙重效應。
選項分析
-
(A) 正確
ARM big.LITTLE 是一種結合高效能 CPU 核心(big)與高能源效率 CPU 核心(LITTLE)的異質多核心(Heterogeneous Multi-core)架構。系統根據工作負載動態切換:重度負載時使用 big 核心,背景或輕量任務時切換至 LITTLE 核心以大幅降低功耗。其主要設計宗旨即為提升系統的能源效率(Energy-efficiency)。 -
(B) 錯誤
根據阿姆達爾定律(Amdahl's Law):
假設目標加速比為 ,處理器數量 ,無法平行化(串行)的程式碼比例為 :
同乘以 :