108 年 國立中央大學資訊工程學系軟體工程碩士班《作業系統與計算機組織》

📄 試題原卷 免費註冊後即可對照原始考卷 PDF免費註冊

第 1 題

Consider a multi-programmed system with degree of 6, that is, six programs in memory at the same time. Assume that each process spends 40% of its time waiting for I/O. What will be the CPU utilization?
(A) 0.6
(B) 0.986176
(C) 0.953344
(D) 0.995904
(E) None of the above

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

  • 多工系統的 CPU 利用率:在多程式系統中,CPU 只有在全部程式同時等待 I/O 時才會閒置。
  • 等待機率:若單一程式有 pp 的機率在任何時刻等待 I/O,則該程式 就緒 的機率為 1−p1-p。
  • 獨立性假設:各程式的 I/O 等待相互獨立,系統的閒置機率為所有程式同時等待的機率 pnp^{n},其中 nn 為多工度(同時駐留於記憶體的程式數)。

解題方法

  1. 依題意,單一程式等待 I/O 的機率 p=0.40p = 0.40。
  2. 多工度 n=6n = 6(同時有 6 個程式)。
  3. 系統閒置機率 =pn=0.406= p^{n}=0.40^{6}。
  4. CPU 利用率 U=1−pn=1−0.406U = 1 - p^{n}=1-0.40^{6}。
  5. 計算 0.4060.40^{6}:
0.402=0.16,  0.403=0.064,  0.404=0.0256,  0.405=0.01024,  0.406=0.0040960.40^{2}=0.16,\; 0.40^{3}=0.064,\; 0.40^{4}=0.0256,\; 0.40^{5}=0.01024,\; 0.40^{6}=0.004096

故

U=1−0.004096=0.995904U = 1 - 0.004096 = 0.995904

選項分析

  • (A) 0.6:等同於單一程式就緒機率 1−p1-p,忽略了多工度的疊加效果,故錯。
  • (B) 0.986176:若以 U=1−(p5)U = 1-(p^{5}) 計算會得到 1−0.405=0.989761-0.40^{5}=0.98976,仍與此值不符,屬於計算錯誤的結果,故錯。
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 2 題

A computer system has the following properties: instruction miss rate = 2%, data miss rate = 4%, the percentage of instructions executing data memory access = 20% and miss penalty = 50 clock cycles. Assume that there is no penalty for a memory hit (CPI=1). Calculate the number of clock cycles, H, required to execute a program with 1111 instructions. What is the value of "Round(H) mod 5"? ("mod" is the modulo operator.)
(A) 0
(B) 1
(C) 2
(D) 3
(E) 4

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

  • 快取未命中率 (miss rate):指存取快取時找不到資料的比例。
  • 未命中懲罰 (miss penalty):一次未命中所需額外的時脈週期。
  • CPI (Cycles Per Instruction):每條指令平均需要的時脈週期,若快取命中則無額外懲罰,此題假設 CPI = 1 為基本值。
  • 指令快取 vs. 資料快取:指令快取只影響每條指令的取指;資料快取只在執行資料存取指令時才會產生影響。

解題方法

  1. 計算每條指令的平均懲罰
    • 指令快取未命中
指令未命中懲罰 per instruction=指令未命中率×未命中懲罰=0.02×50=1  cycle\text{指令未命中懲罰 per instruction}= \text{指令未命中率}\times \text{未命中懲罰} =0.02 \times 50 = 1\;\text{cycle}
  • 資料快取未命中
    只有 20% 的指令會執行資料存取,因此每條指令的平均資料未命中懲罰為
資料未命中懲罰 per instruction=0.20×(資料未命中率×未命中懲罰)=0.20×(0.04×50)=0.20×2=0.4  cycle\text{資料未命中懲罰 per instruction}=0.20 \times (\text{資料未命中率}\times \text{未命中懲罰}) =0.20 \times (0.04 \times 50)=0.20 \times 2 =0.4\;\text{cycle}
  1. 求每條指令的總 CPI

CPItotal=1  (基本 CPI)+1  (指令未命中)+0.4  (資料未命中)=2.4\text{CPI}_{\text{total}} = 1\;(\text{基本 CPI}) + 1\;(\text{指令未命中}) + 0.4\;(\text{資料未命中}) = 2.4

  1. 求整個程式的總時脈週期

H=指令數×CPItotal=1111×2.4=2666.4H = \text{指令數}\times \text{CPI}_{\text{total}} = 1111 \times 2.4 = 2666.4

  1. 四捨五入後取整數

Round(H)=Round(2666.4)=2666\text{Round}(H)=\text{Round}(2666.4)=2666

  1. 求模 5 的餘數

2666 mod 5=12666 \bmod 5 = 1

選項分析

🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 3 題

A, B, C and D are four IEEE754 single-precision floating-point values. A is the largest
denormalized number. B is the smallest positive normalized number. C=-2.25. D
represents positive infinity. Now E= A XOR B XOR C XOR D. The number of "1" in E is
"K". What is "K mod 5"?
(A) 0
(B) 1
(C) 2
(D) 3
(E) 4

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

IEEE 754 單精度格式共 32 位元:1 位元符號、8 位元指數(bias = 127)、23 位元尾數。四個特殊值的編碼:

  • 非正規化數(denormalized):指數欄位全 0,尾數不為 0,無隱含的前導 1。
  • 最小正規化數:指數欄位 00000001200000001_2、尾數全 0。
  • 正無限大:指數欄位全 1、尾數全 0、符號為 0。
  • 一般浮點數需先轉成 ±1.f×2e\pm 1.f \times 2^e 再編碼。

解題方法

  1. A 為最大非正規化數:指數 0、尾數 23 個 1,編碼為 0x007FFFFF0x007FFFFF。
  2. B 為最小正規化數:指數 1、尾數 0,編碼為 0x008000000x00800000。
  3. C =−2.25=−10.012=−1.0012×21= -2.25 = -10.01_2 = -1.001_2 \times 2^1:符號 1,指數 1+127=128=1000000021+127=128=10000000_2,尾數 001001 後補 0,故二進位為 1 10000000 001000000000000000000001\ 10000000\ 00100000000000000000000,即 0xC01000000xC0100000。
  4. D 為 +∞+\infty:符號 0、指數全 1、尾數全 0,即 0x7F8000000x7F800000。

逐步做 XOR:

A⊕B=0x007FFFFF⊕0x00800000=0x00FFFFFFA \oplus B = 0x007FFFFF \oplus 0x00800000 = 0x00FFFFFF

0x00FFFFFF⊕0xC0100000=0xC0EFFFFF0x00FFFFFF \oplus 0xC0100000 = 0xC0EFFFFF

0xC0EFFFFF⊕0x7F800000=0xBF6FFFFF0xC0EFFFFF \oplus 0x7F800000 = 0xBF6FFFFF

計算 E=0xBF6FFFFFE = 0xBF6FFFFF 中 1 的個數:

🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 4 題

Given a 16-word two-way set associative cache with two-word blocks, for the
following word address memory access: 12, 17, 18, 16, 5, 29, 19, 12, 4, 22, 23, 24, 17,
25, 26, 27, assume that LRU is used and the number of hit is "K". What is "K mod 5"?
(A) 0
(B) 1
(C) 2
(D) 3
(E) 4

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

  • 快取結構:16 個字 (word)容量、兩路組合相聯 (2‑way set associative)、每個區塊 2 個字。
    • 區塊數 = 16 / 2 = 8 塊。
    • 每組 (set) 2 塊 → 組數 = 8 / 2 = 4 組。
  • 位元切割(以 word address 為單位)
    • 區塊位元 (offset) = log⁡22=1\log_2 2 = 1 位。
    • 組位元 (index) = log⁡24=2\log_2 4 = 2 位。
    • 標籤 (tag) = 其餘高位元。
  • 映射公式
    • block_num=⌊address2⌋\text{block\_num} = \left\lfloor\frac{\text{address}}{2}\right\rfloor
    • set_idx=block_num mod 4\text{set\_idx} = \text{block\_num} \bmod 4
    • tag=⌊block_num4⌋\text{tag} = \left\lfloor\frac{\text{block\_num}}{4}\right\rfloor
  • 置換政策:LRU (Least Recently Used) 於兩路組合相聯的每組內獨立執行。

解題方法

  1. 依序將每個存取位址換算成 block number、set index、tag。
  2. 針對該 set 檢查目前快取內的兩個 block 是否已含相同 tag:
    • 若已有 → Hit,更新該組的 LRU 狀態。
    • 若沒有 → Miss,若組內尚有空位則直接塞入;若已滿則根據 LRU 驅除最舊的 block,再放入新 block。
  3. 整個序列完成後統計命中次數 KK,求 K  mod  5K\ \bmod\ 5。

以下以表格呈現每一步的計算與結果( H = Hit、M = Miss):

存取位址block = ⌊addr/2⌋set = block mod 4tag = ⌊block/4⌋快取狀態變化命中?
12621M → set2: {1}M
17802M → set0: {2}M
18912M → set1: {2}M
16802H (set0已有2)H
5220M → set2: {1,0}M
291423M (replace LRU=1) → set2: {0,3}M
19912H (set1已有2)H
12621M (replace LRU=0) → set2: {3,1}M
4220M (replace LRU=3) → set2: {1,0}M
221132M → set3: {2}M
231132H (set3已有2)H
241203M → set0: {2,3}M
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 5 題

For a pipelined implementation, assume that 1/4 of the load instructions are
immediately followed by an instruction that uses the result, half of the branches are
miss-predicted with 1 clock cycle delay, and jumps always cause 1 clock cycle of
delay. If the instruction mix is 24% loads, 20% stores, 30% ALU instructions, 20%
branches, and 6% jumps. The average CPI is "K". What is "Round(K*234) mod 5"?
(A) 0
(B) 1
(C) 2
(D) 3
(E) 4

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

  • 流水線基本 CPI:在理想情況(無任何資料相依與分支衝突)下,流水線每條指令只佔 1 個時脈週期,即基礎 CPI = 1。
  • 額外停頓週期:任何因相依或分支預測失誤而產生的氣泡,都會在平均 CPI 中累加「指令比例 × 停頓週期」的貢獻。
  • 加權平均:CPI=1+∑i(比例i×每條指令額外週期i)CPI = 1 + \sum_i (\text{比例}_i \times \text{每條指令額外週期}_i)

解題方法

  1. 列出每種指令的額外停頓
    • Load:1/41/4 的 load 之後緊跟使用其結果的指令,需要 1 個週期 的 stall。

額外週期load=14×1=0.25\text{額外週期}_{\text{load}} = \frac14 \times 1 = 0.25

  • Branch:50%50\% 的 branch 被錯誤預測,產生 1 個週期 的延遲。

額外週期branch=0.5×1=0.5\text{額外週期}_{\text{branch}} = 0.5 \times 1 = 0.5

  • Jump:所有 jump 都必定產生 1 個週期 的延遲。

額外週期jump=1×1=1\text{額外週期}_{\text{jump}} = 1 \times 1 = 1

  • Store、ALU:題目未提及任何停頓,視為 00。
  1. 以指令混合比例加權
指令類型比例額外週期/指令加權貢獻
Load24%=0.2424\% = 0.240.250.250.24×0.25=0.060.24 \times 0.25 = 0.06
Store20%=0.2020\% = 0.200000
ALU30%=0.3030\% = 0.300000
Branch20%=0.2020\% = 0.200.50.50.20×0.5=0.100.20 \times 0.5 = 0.10
Jump6%=0.066\% = 0.06110.06×1=0.060.06 \times 1 = 0.06

總額外週期

0.06+0.10+0.06=0.220.06 + 0.10 + 0.06 = 0.22

  1. 求平均 CPI

K=1+0.22=1.22K = 1 + 0.22 = 1.22

  1. 計算題目要求的數值

K×234=1.22×234=285.48K \times 234 = 1.22 \times 234 = 285.48

取四捨五入(Round)得到 285285。
再取模 55:

285 mod 5=0285 \bmod 5 = 0

選項分析

🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 6 題

Which of the following statements are true:
(A) Superscalar machines main rely on hardware to achieve instruction-level
parallelism.
(B) Page table is a cache.
(C) TLB is a cache.
(D) The major advantage of microprogramming control is its speed.
(E) The case that "TLB hit but cache miss" is possible.

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

  1. Superscalar 與指令級平行 (ILP)
    • Superscalar 處理器同一個時脈週期內可發射多條指令,主要依賴硬體的 動態排程 (dynamic scheduling)、指令解碼 (multiple issue)、執行單元多元化,而非編譯器的靜態排程。
  2. 快取 (Cache) 的概念
    • 快取是一種 暫存機制,用來減少對較慢層次記憶體的存取次數。快取的本質是「將較慢層次的資料暫存於較快層次」。
  3. 頁表 (Page Table)
    • 虛擬記憶體系統中,頁表是一個 映射結構 (VPN → PPN)。每一次記憶體訪問若要轉譯,需要查詢頁表;因為查詢成本高,通常在硬體中加入 TLB 以快取近期的轉譯結果。
  4. TLB (Translation Lookaside Buffer)
    • TLB 本質上是 頁表的快取,存放最近使用的虛擬頁號與實體頁框號的對應關係,屬於 地址轉譯快取。
  5. 微程式控制 (Microprogramming)
    • 微程式化的控制單元以 微指令 方式實現指令的控制訊號。其優點是 可延伸性、易於修改,但因需逐條執行微指令,速度較 硬體直接編碼 (hard‑wired control) 慢。

解題方法
本題為多選題,重點在於辨識每個敘述是否符合上述概念。對每個選項直接比對其描述與正確定義,若敘述與概念相符即為 True,否則 False。


選項分析

選項判斷理由
(A) Superscalar machines mainly rely on hardware to achieve instruction‑level parallelism.TrueSuperscalar 依賴硬體結構(多發射單元、動態排程、分支預測、寫入背壓等)來同時執行多條指令。編譯器的靜態排程只能提供有限幫助,主要平行度仍由硬體決定。
(B) Page table is a cache.False頁表是 映射表,保存所有虛擬頁與實體頁的對應關係;它本身不具備快取機制(如替換、命中率概念),而是 完整 的映射結構。快取的概念是「把較慢層的資料暫存於較快層」,頁表不是暫存,而是 來源。
(C) TLB is a cache.TrueTLB 正是 頁表快取,存放最近被訪問的頁表條目,具備快取的典型特性(容量有限、替換策略、命中/未命中)。因此可視為 address‑translation cache。
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 7 題

Which of the following statements are true for the single-cycle CPU design and the
multi-cycle CPU design?
(A) The clock rate of the multiple-cycle CPU design is larger than single-cycle CPU
design.
(B) The CPI of the single-cycle CPU is 1.
(C) The throughput of the single-cycle CPU is larger than multiple-cycle CPU.
(D) The cycle time of the multi-cycle CPU is determined by the slowest
instruction.
(E) All the above.

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

  • 單循環 (single‑cycle) CPU:每條指令在同一個時脈週期內完成。時脈週期長度必須足以容納最慢指令的全部微操作路徑。
  • 多循環 (multi‑cycle) CPU:指令被切分成多個微操作,每個微操作佔一個時脈週期。時脈週期長度只受最慢 微操作(而非最慢整條指令)限制。
  • 時脈頻率 (clock rate):f=1Tcyclef = \frac{1}{T_{\text{cycle}}},TcycleT_{\text{cycle}} 為時脈週期。
  • CPI (Cycles Per Instruction):平均每條指令需要的時脈週期數。單循環 CPU 的 CPI 恒為 1。
  • 吞吐量 (throughput):單位時間內完成的指令數,公式 Throughput=fCPI\text{Throughput}= \frac{f}{\text{CPI}}。

解題方法
逐一檢視每個敘述,套用上述概念與公式判斷其真偽。若涉及比較(如時脈頻率或吞吐量),以「最慢的微操作」與「最慢的指令」的差異作為關鍵判斷點。


選項分析

選項判斷理由
(A) The clock rate of the multiple‑cycle CPU design is larger than single‑cycle CPU design.✅ 正確多循環 CPU 的時脈週期只需容納最慢 微操作,通常遠小於需容納最慢整條指令的單循環 CPU 時脈週期,因而得到較高的時脈頻率 fmulti>fsinglef_{\text{multi}} > f_{\text{single}}。
(B) The CPI of the single‑cycle CPU is 1.✅ 正確單循環 CPU 每條指令在同一個時脈週期內完成,定義上 CPI = 1。
(C) The throughput of the single‑cycle CPU is larger than multiple‑cycle CPU.❌ 錯誤吞吐量 fCPI\frac{f}{\text{CPI}}:雖然單循環 CPU 的 CPI 較小(=1),但其時脈頻率較低;多循環 CPU 時脈頻率較高但 CPI>1。
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 8 題

Consider the following MIPS instructions.
add s0,s0, t0, t1subt1 sub t2, s0,s0, t3
Which of the following statements are true?
(A) There is a Read-After-Write hazard.
(B) There is a Write-After-Write hazard.
(C) We may use data forwarding to solve the above Read-After-Write hazard.
(D) We may insert bubbles to solve the above Write-After-Write hazard.
(E) All the above.

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

本題在原卷「多重選擇(一題 5 分,答錯不倒扣)」大題中,是多選題,要選出所有正確敘述。

管線中的資料危障(data hazard)三種類型,以「前一指令 i、後一指令 j」來看:

  • RAW(Read After Write,真相依):j 要讀 i 寫入的暫存器。這是 MIPS 五級管線中唯一會發生的資料危障。
  • WAR(Write After Read,反相依):j 要寫 i 讀取的暫存器。
  • WAW(Write After Write,輸出相依):i、j 寫同一個暫存器。

在依序執行、統一在 WB 階段寫回的 MIPS 五級管線中,WAR 與 WAW 不會造成危障;它們在亂序執行的處理器才需要處理(以暫存器重新命名解決)。

分析這兩條指令

add $s0, $t0, $t1    # 寫 $s0
sub $t2, $s0, $t3    # 讀 $s0,寫 $t2
  • sub 讀取 add 剛寫入的 $s0 → RAW 相依。
  • 兩條指令寫入的暫存器不同($s0、$t2)→ 沒有 WAW。

選項分析

  • (A) 存在 RAW 危障:正確,sub 需要 add 的結果 `
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 9 題

Which of the following statements are true for branch instructions and branch prediction?
(A) The jump instruction in MIPS is a conditional branch instruction.
(B) A branch target buffer is used by the compiler to make predictions.
(C) Branch prediction is more important when pipelines are longer.
(D) When branch prediction fails, we need to flush instructions and correct PC.
(E) All the above.

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

本題考分支指令(branch)、分支預測(branch prediction)與管線危障(hazard)。重點:條件分支與無條件跳躍的差別、branch target buffer(BTB)屬硬體機制、管線越深預測錯誤的代價越大。

解題方法

逐項對照管線架構的基本概念判斷:

  • 預測錯誤時,已抓進管線的錯誤路徑指令必須作廢,並把 PC 改回正確位址,這就是「分支懲罰」(branch penalty)。
  • 管線越深,分支條件越晚才能判定,預測錯誤要沖掉的指令越多,所以預測越重要。

選項分析

  • (A) 錯誤。MIPS 的 j(jump)是無條件跳躍,一定跳;條件分支是 beq、bne 這類依暫存器比較結果決定是否跳的指令。
  • (B) 錯誤。branch target buffer 是處理器硬體內的小型快取,記錄分支指令位址與其目標位址,在取指(IF)階段由硬體查詢;編譯器不會使用 BTB 做預測(編譯器頂多做靜態的分支提示或指令排程)。
  • (C) 正確。
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 10 題

Consider a pipelined CPU with the following five stages like MIPS: Instruction Fetch (IF), Instruction Decode (ID), Execution (EXE), Memory Access (MEM), and Register Write Back (WB). Which of the following statements are true?
(A) Compared with non-pipelined CPU, the speed up can be up to twice the number of stages.
(B) In order to resolve control hazard, we should move the branch execution from MEM to IF.
(C) Instruction work at each stage should be imbalanced to improve pipeline performance, because such a design allows some stages do more work.
(D) Branch hazard is due to a data cache miss.
(E) None of the above.

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

本題考 5 級管線(IF、ID、EXE、MEM、WB)的加速比、控制危障(control hazard)的解法,以及管線階段平衡的設計原則。

解題方法

管線的理想加速比:

Speedup=非管線化每道指令時間管線化時脈週期≤n\text{Speedup} = \frac{\text{非管線化每道指令時間}}{\text{管線化時脈週期}} \le n

其中 nn 為階段數,前提是各階段延遲相等且無停頓。因此 5 級管線的理想加速比上限是 5 倍,並不會超過階段數。

選項分析

  • (A) 錯誤。加速比上限約等於階段數(這裡為 5 倍),不是「階段數的兩倍」(10 倍)。管線化提升的是吞吐量,並不縮短單一指令的延遲,而且有危障與暫存器開銷,實際值更低。
  • (B) 錯誤。降低控制危障懲罰的做法,是把分支的判斷與目標位址計算「提前」到 ID 階段(加比較器與加法器),而不是移到 IF。IF 階段指令尚未取回、解碼,根本無法判斷是否為分支以及比較暫存器。
  • (C) 錯誤。各階段的工作量應「平衡」。時脈週期由最慢的階段決定,若某階段工作特別重,其他階段只能陪著等,反而拉長週期、降低效能。
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 11 題

The MIPS instructions of a program are composed as follows.

addaddibeqlwsw
30%20%25%15%10%

Which of the following statements are true?
(A) The instruction memory is used by 50% of the cycles.
(B) The data memory is used by 25% of the cycles.
(C) The input of the sign-extended circuit is used by 70% of the cycles.
(D) The MemtoReg signal is on for 25% of the cycles.
(E) None of the above.

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

利用單週期 MIPS 資料路徑,分析每種指令使用哪些功能單元與控制訊號,再依指令比例加權計算使用率。

解題方法

各指令使用的元件:

指令Instruction memorySign-extend 輸入Data memoryMemtoReg = 1
add(30%)用不用不用否
addi(20%)用用(立即值)不用否
beq(25%)用用(位移量)不用不關心
lw(15%)用用(位移量)讀是
sw(10%)用用(位移量)寫不關心

(add 是 R-type,指令中的低 16 位元是 rd、shamt、funct 欄位,並非立即值,其結果不需要符號延伸。)

選項分析

  • (A) 錯誤。每道指令都需要從 instruction memory 取指令,使用率為 100%,不是 50%。
  • (B) 正確。只有 lw(15%)與 sw(10%)會存取 data memory,合計 15%+10%=25%15\%+10\% = 25\%。
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 12 題

Some computer systems do not provide a privileged mode of operation in hardware. An operating system for a machine of this type would need to remain in control (or monitor mode) at all times. This could be accomplished by the following methods:
(A) Software interpretation of all user programs.
(B) All programs are written in high-level languages. The compiler would generate the protection checks that the hardware is missing.
(C) Program executing in cloud server.
(D) Open sourced user program.
(E) ROM-based operating system.

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

現代作業系統靠硬體提供的 dual-mode(使用者模式/核心模式)與特權指令來保護系統:使用者程式不能直接執行 I/O、改記憶體保護暫存器等特權操作。若硬體沒有特權模式,OS 就必須用軟體手段「隨時都握有控制權」,確保每個使用者動作都經過檢查。

解題方法

判斷每個選項能否「在不靠硬體特權模式下,強制檢查使用者程式的每一個動作」:

  • 軟體直譯器可以在執行每一道指令前先檢查其合法性。
  • 若所有程式都由受信任的編譯器產生,編譯器可在產生的程式碼中安插保護檢查(如邊界檢查、禁止直接 I/O,所有特權操作須透過 OS 呼叫)。

選項分析

  • (A) 正確。以軟體直譯(interpret)所有使用者程式,每執行一道指令前,OS 先檢查是否違規,才代為執行,OS 因此一直處於控制地位。
  • (B) 正確。所有程式都用高階語言撰寫,由編譯器產生程式碼,編譯器負責插入硬體所缺少的保護檢查(例如陣列範圍與記憶體存取檢查),使程式無法繞過 OS。
  • (C) 錯誤。
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 13 題

Consider a preemptive priority scheduling algorithm based on dynamically changing priorities. Larger priority numbers imply higher priority.
When a process is waiting for the CPU (in the ready queue, but not running), its priority changes at a rate A; when it is running, its priority changes at a rate B. All processes are given a priority of 0 when they enter the ready queue. The parameters A and B can be set to give many different scheduling algorithms.
What is the algorithm that results from A < B < 0? Or A > B > 0?
(A) RR
(B) FCFS
(C) SJF
(D) LIFO
(E) Random

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

動態優先權排程:每個行程進入就緒佇列時優先權為 0,等待時優先權以速率 AA 變化,執行時以速率 BB 變化,優先權數字越大代表越優先、可搶占。比較「誰的優先權較高」可看相對增減量。

解題方法

情形一:A<B<0A<B<0

兩種狀態優先權都下降,且等待中降得更快(AA 更負)。

  • 新進行程優先權為 0,而其他行程(不論等待或執行)優先權都已是負值,所以新進者優先權最高,立即搶占。
  • 在所有已存在的行程之間:執行中的行程下降得比等待中的慢,所以正在執行的行程永遠比等待者優先權高,不會被已在佇列的行程搶走。
  • 結果:最晚到的行程最先執行(後進先出),為 LIFO。

情形二:A>B>0A>B>0

兩種狀態優先權都上升,且等待中上升得更快。

  • 等待越久,累積的優先權越高,因此先到的行程(等最久)優先權最高。
  • 執行中的行程上升得較慢,所以不會被新進者(優先權 0)搶占,且最終會被等更久的行程超越,但其間先進者始終排在前面。
  • 結果:依到達順序服務,為 FCFS。

選項分析

🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 14 題

Consider a multiprocessor system and a multithreaded program written using the many-to-many threading model. Let the number of user-level threads in the program be more than the number of processors in the system. What are the lower performance implications of the following scenarios.
(A) The number of kernel threads allocated to the program is less than the number of processors.
(B) The number of kernel threads allocated to the program is equal to the number of processors.
(C) The number of kernel threads allocated to the program is greater than the number of processors but less than the number of userlevel threads.
(D) The number of kernel threads allocated to the program is equal to two.
(E) The number of kernel threads allocated to the program is greater than the number of processors and also greater than the number of userlevel threads.

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

Many-to-many 執行緒模型:多個 user-level thread 對映到數目較少或相等的 kernel thread,再由 kernel thread 排到處理器上執行。效能取決於 kernel thread 的數量與處理器數、user thread 數的關係:

  • kernel thread 太少 → 處理器用不滿。
  • kernel thread 剛好等於處理器數 → 一旦其中一個因 blocking system call 被擋住,對應處理器就閒置。
  • kernel thread 略多於處理器數 → 阻塞時可立即換另一個 kernel thread 上,處理器不閒置。
  • kernel thread 多於 user thread → 多出的 kernel thread 沒有 user thread 可跑,只是浪費資源,不會再變差。

解題方法

本題問的是「效能較差(lower performance)」的情形,逐項評估:

選項分析

  • (A) kernel thread 數小於處理器數:必有處理器沒有 kernel thread 可執行而閒置,無法發揮平行度,效能較低。
  • (B) kernel thread 數等於處理器數:所有處理器都可被利用;只有當某個 kernel thread 因 blocking system call 阻塞時,才會讓一顆處理器暫時閒置,並非必然變差。
  • (C) 大於處理器數但小於 user thread 數:這是最理想的配置,某個 kernel thread 阻塞時還有備用的 kernel thread 補上,處理器不會閒置,效能最好。
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 15 題

In a real computer system, neither the resources available nor the demands of processes for resources are consistent over long periods (months). Resources break or are replaced, new processes come and go, new resources are bought and added to the system. If deadlock is controlled by the banker's algorithm, which of the following changes can be made safely (without introducing the possibility of deadlock), and under what circumstances?
(A) Increase Available (new resources added)
(B) Decrease Available (resource permanently removed from system)
(C) Increase Max for one process (the process needs or wants more resources than allowed).
(D) Decrease Max for one process (the process decides it does not need that many resources)
(E) Decrease the number of processes

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

銀行家演算法(Banker's algorithm)用「安全狀態(safe state)」避免死結:只有在存在一個安全序列、使所有行程都能依序取得其最大需求並完成時,系統才處於安全狀態。其資料結構為 Available、Max、Allocation 與 Need(Need=Max−Allocation\text{Need}=\text{Max}-\text{Allocation})。

解題方法

判斷每種更動是否「必然不會使安全狀態變成不安全」:

  • 讓系統「更寬鬆」的更動(可用資源變多、需求變少、行程變少)必然保持安全。
  • 讓系統「更吃緊」的更動(可用資源變少、需求變多)可能破壞安全序列,必須重新檢查,只有確認新狀態仍安全時才能進行。

選項分析

  • (A) 增加 Available:原有的安全序列仍然成立(資源只多不少),可隨時安全進行。正確。
  • (B) 減少 Available:可能使某些行程再也湊不齊所需資源,系統可能變成不安全,必須在移除後重新做安全性檢查,只有仍安全才可以,並非任何情況都安全。錯誤。
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 16 題

Consider the following page reference string:
7, 2, 3, 1, 2, 5, 3, 4, 6, 7, 7, 1, 0, 5, 4, 6, 2, 3, 0, 1.
Assuming demand paging with three frames, how many page faults would occur for the following replacement algorithms?

  • LRU replacement
  • FIFO replacement
  • Optimal replacement

Select the correct answers:
(A) 18 for LRU
(B) 17 for LRU
(C) 17 for FIFO
(D) 13 for LRU
(E) 13 for optimal replacement

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

Demand paging 配置 3 個 frame,分別以 LRU(最久未使用者換出)、FIFO(最先進入者換出)與 Optimal(未來最久不會用到者換出)計算 page fault 次數。參考字串共 20 個:

7,2,3,1,2,5,3,4,6,7,7,1,0,5,4,6,2,3,0,17,2,3,1,2,5,3,4,6,7,7,1,0,5,4,6,2,3,0,1

解題方法

逐步模擬(F 表示 page fault,H 表示命中;frame 內容括號中列出)。

LRU(括號內由最舊到最新)

步參考結果Frame 內容
17F7
22F7, 2
33F7, 2, 3
41F2, 3, 1(換出 7)
52H3, 1, 2
65F1, 2, 5(換出 3)
73F2, 5, 3(換出 1)
84F5, 3, 4(換出 2)
96F3, 4, 6(換出 5)
107F4, 6, 7(換出 3)
117H4, 6, 7
121F6, 7, 1(換出 4)
130F7, 1, 0(換出 6)
145F1, 0, 5(換出 7)
154F0, 5, 4(換出 1)
166F5, 4, 6(換出 0)
172F4, 6, 2(換出 5)
183F6, 2, 3(換出 4)
190F2, 3, 0(換出 6)
201F3, 0, 1(換出 2)

命中 2 次,LRU 共 20−2=1820-2=18 次 page fault。

FIFO

步參考結果Frame(由先進到後進)
1~37,2,3F,F,F7, 2, 3
41F2, 3, 1
52H2, 3, 1
65F3, 1, 5
73H3, 1, 5
84F1, 5, 4
96F5, 4, 6
107F4, 6, 7
117H4, 6, 7
121F6, 7, 1
130F7, 1, 0
145F1, 0, 5
154F0, 5, 4
166F5, 4, 6
172F4, 6, 2
183F6, 2, 3
190F2, 3, 0
201F3, 0, 1

命中 3 次,FIFO 共 20−3=1720-3=17 次 page fault。

Optimal

步參考結果Frame 內容(及換出者)
1~37,2,3F7, 2, 3
41F2, 3, 1(換出 7,最晚才再用到)
52H2, 3, 1
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 17 題

Two threads from different processes share:
(A) Global variables
(B) Heap
(C) File descriptors
(D) Program counter
(E) None of the above

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

行程(process)是資源分配的單位,每個行程擁有獨立的位址空間;執行緒(thread)是排程單位。「同一行程內」的執行緒共享程式碼、資料(全域變數)、heap 與開啟的檔案;每個執行緒各自擁有 program counter、暫存器與堆疊。

解題方法

本題的前提是「兩個執行緒來自不同的行程」。因為不同行程之間的位址空間彼此隔離,資源不能共享,所以逐項檢查:

選項分析

  • (A) 全域變數:每個行程有自己獨立的資料段,不同行程的執行緒看到的是各自的副本,不共享。錯誤。
  • (B) Heap:heap 屬於行程的位址空間,不同行程各有一份,不共享。錯誤。
  • (C) File descriptor:file descriptor 表是每個行程私有的(即使 fork 後子行程繼承了副本,各自的表仍是獨立的),不同行程的執行緒不共享同一份表。錯誤。
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 18 題

CPU scheduling decisions may take place when a process
(A) Switches from the running state to the waiting state
(B) Switches from the waiting state to the ready state
(C) Switches from the ready state to the running state
(D) Switches from the running state to the decision state
(E) None of the above

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

CPU 排程程式(scheduler)需要做決策的時機,依行程狀態轉換分為四種:

  1. 行程由 running 變為 waiting(例如發出 I/O 請求,或等待子行程結束)。
  2. 行程由 running 變為 ready(例如發生中斷、時間片用完)。
  3. 行程由 waiting 變為 ready(例如 I/O 完成)。
  4. 行程終止。

其中 1 與 4 屬於非搶占式排程也必須決策的時機(因為 CPU 被釋放了),2 與 3 則是搶占式排程才有的決策點。

解題方法

把選項的狀態轉換與上述四種逐一對照。

選項分析

  • (A) running → waiting:是第 1 種,CPU 閒下來,必須選下一個行程。正確。
  • (B) waiting → ready:是第 3 種,新就緒的行程可能優先權較高,需要決定是否搶占。正確。
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 19 題

Choose the correct statements from the multiple choices
(A) A smaller page size leads to smaller page tables.
(B) A smaller page size leads to more TLB misses.
(C) The Round robin (RR) scheduling algorithm optimizes CPU throughput.
(D) The Round robin (RR) scheduling algorithm is preemptive.
(E) None of the above.

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

本題綜合記憶體管理(分頁大小對頁表與 TLB 的影響)與 CPU 排程(Round Robin 的特性)。

解題方法與選項分析

  • (A) 錯誤。位址空間大小固定時,頁面數量為:

頁數=位址空間大小頁面大小\text{頁數} = \frac{\text{位址空間大小}}{\text{頁面大小}}

頁面越小、頁數越多,頁表項目越多,頁表就越大。這是分頁大小設計的取捨:小頁面減少內部碎片,但頁表變大。

  • (B) 正確。TLB 的容量固定(項目數有限),其涵蓋範圍(TLB reach)為:

TLB reach=項目數×頁面大小\text{TLB reach} = \text{項目數} \times \text{頁面大小}

頁面越小,TLB 能涵蓋的記憶體越少,所以 TLB miss 機率越高。

  • (C) 錯誤。Round Robin 以固定時間片輪流執行,強調公平與回應時間;頻繁的 context switch 帶來額外開銷,會降低 CPU throughput。
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 20 題

Choose the correct statements from the multiple choices regarding networking.
(A) ARP protocol is used to discover a MAC address, associated with a given IP address.
(B) DNS translates domain names to IP addresses.
(C) IPSec can be used in VPNs.
(D) ICMP messages can be used for diagnose errors in IP operations.
(E) None of the above.

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

本題考網路各層常見協定的用途:資料連結層與網路層之間的位址解析(ARP)、應用層的名稱解析(DNS)、網路層安全(IPSec)與網路層的錯誤回報(ICMP)。四個協定各有明確職責,答題只要把「做什麼」對上「在哪一層」即可。

解題方法

逐項回想協定的定義與典型使用情境,判斷敘述是否與標準功能一致。

選項分析

  • (A) 正確。ARP(Address Resolution Protocol)在同一區域網路內,以廣播詢問「誰擁有這個 IP 位址?」,持有該 IP 的主機回覆自己的 MAC 位址,發送端再把結果快取在 ARP table。因此 ARP 的功能就是由 IP 位址查出對應的 MAC 位址。
  • (B) 正確。DNS(Domain Name System)是分散式的階層式資料庫,把人類易記的網域名稱(如 www.ncu.edu.tw)解析成 IP 位址(A/AAAA 紀錄),也支援反向查詢。
  • (C) 正確。IPSec 在 IP 層提供認證(AH)與加密(ESP),可用 transport mode 或 tunnel mode;其中 tunnel mode 常用於站對站 VPN 與遠端存取 VPN,是建立 VPN 最常見的技術之一。
  • (D) 正確。
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

其他考古題