免費詳解 / 中央 / 硬體 / 102

102 中央資工所考古題解答|硬體逐題詳解

102 中央資工所硬體考古題的逐題詳解,共 20 題,免費公開。

逐題詳解

15 分

Which of the following statement(s) should be true?

(a) There are more addressing modes in CISC than in RISC.

(b) Microprogramming is usually used in CISC since this kind of control can be executed faster.

(c) Horizontal microinstructions are executed faster than Vertical microinstructions.

(d) Using ROM in the control designs can usually save the space or cost, when compared with PLA.

(e) None of the above is true.

(a) CISC 的 addressing mode 多、RISC 少 → T

(b) microprogrammed control 要先讀 control store,比 hardwired 慢;CISC 用它是因為指令複雜、好實作 → F

(c) horizontal 每個 control signal 一個 bit,不用 decode;vertical 要多一層 decoder → T

(d) control function 稀疏時 PLA 只放用到的 product term,比 ROM(全部 minterm 都要有一格)省 → F

(a), (c)

25 分

About the performance analysis, which of the following statement(s) should be true?

(a) Assume that a C program is compiled into 1000 machine instructions, which are related to the size of the executable file. Then, the average execution time is usually equal to multiplying 1000 (instructions) by its average CPI and the clock cycle time.

(b) In evaluating the performance by using the benchmark tests, we usually use the geometric mean to calculate the average value among various test results.

(c) MIPS is not a reliable metric since it provides the wrong results when we compare the performances of a compiled program running on two machines with the same instruction set architecture.

(d) It is usually a preferred approach to consider only one of the three factors: clock rate, CPI or the instruction count, and then try to improve it to decrease the execution time. That is called a divide-and-conquer methodology.

(e) None of the above is true.

(a) 1000 是檔案裡的靜態指令數;CPU time 要乘的是實際執行的動態指令數,有迴圈就不同 → F

(b) benchmark 的結果先對 reference machine 正規化成比值,比值要用 geometric mean 平均(SPEC) → T

(c) 同一個 ISA、同一支編譯後程式,instruction count 一樣,MIPS 高就是比較快;MIPS 會失真是跨 ISA 比較時 → F

(d) \(\text{CPU time}=IC\times CPI\times T_{clk}\),三者互相牽動,不能只改善其中一個 → F

(b) 是指 benchmark 的結果以正規化比值(SPECratio)表示;若是對原始 execution time 直接平均,則用 arithmetic mean

(b)

35 分

About the memory hierarchy, which of the following statement(s) should be true?

(a) A page fault happens if a page that is not in the physical memory is accessed.

(b) TLB is a data cache of main memory.

(c) Adding a secondary cache can help to reduce the miss rate.

(d) We can always increase the size of cache to improve the cache performance.

(e) None of the above is true.

(a) page fault 的定義 → T

(b) TLB 快取的是 page table 的 entry(位址轉換),不是 main memory 的資料 → F

(c) 加 L2 是降低 L1 miss 之後的 miss penalty,L1 本身的 miss rate 不變 → F

(d) cache 變大 hit time 變長、成本與功耗也增加 → F

(c):從整體 global miss rate 看會下降;題目要考的是 secondary cache 屬於降低 miss penalty 的手段

(a)

45 分

Peterson's solution is a software-based solution to the critical-section problem. For two processes accessing a shared variable, Peterson's solution provides:

(a) Hold and wait (b) Progress (c) Mutual exclusion (d) Circular wait (e) None of the above

Peterson 滿足 critical-section 的三個要求:mutual exclusion、progress、bounded waiting

(a)(d) hold and wait、circular wait 是 deadlock 的必要條件,不是 Peterson 提供的性質 → F

(b) progress → T

(c) mutual exclusion → T

(b), (c)

55 分

Choose the correct statements from the multiple choices regarding the process management.

(a) The fork() system call is able to create a new process.

(b) The fork() system call is able to determine how much sharing is to take place between the parent and child tasks.

(c) Linux provides the ability to create threads using the clone() system call.

(d) A new program is run after a call to exec().

(e) None of the above

(a) fork() 複製出 child process → T

(b) 決定 parent、child 共享多少的是 clone() 的 flags,不是 fork() → F

(c) Linux 用 clone() 建立 thread → T

(d) exec() 以新程式取代目前 process 的記憶體映像並開始執行 → T

(a), (c), (d)

65 分

Choose the correct statements from the multiple choices regarding virtualization.

(a) The guest operating system runs on top of host operation system.

(b) In para-virtualization, a guest operating system runs unmodified on a hypervisor.

(c) Para-virtualization presents the guest with a system that is identical to the guest's preferred system.

(d) Both of virtual user mode and virtual kernel mode run in a physical user mode on the host.

(e) None of the above

(a) hosted(type 2)VMM 下 guest OS 疊在 host OS 之上 → T

(b) para-virtualization 的 guest OS 要修改(改用 hypercall) → F

(c) 給 guest「與它預期的機器完全相同」的是 full virtualization;para 給的是類似但不相同的介面 → F

(d) virtual kernel mode 在實體機器上仍是 user mode 執行,特權指令 trap 進 VMM 再模擬 → T

(a) 只在 type 2 hosted 成立;type 1/type 0 的 VMM 之下沒有 host OS

(a), (d)

75 分

Choose the correct statements from the multiple choices regarding network protocols.

(a) IPv6 does not define broadcasting.

(b) IPv6 supports anycasting.

(c) ARP protocol is used for resolution of network layer addresses into link layer addresses.

(d) DNS converts domain names to IP addresses.

(e) None of the above

(a) IPv6 以 multicast 取代 broadcast → T

(b) IPv6 有 anycast address → T

(c) ARP:IP address → MAC address → T

(d) DNS:domain name → IP address → T

(a), (b), (c), (d)

85 分

What are the advantages of register-register ALU instruction type compared with register-memory ALU instruction type and memory-memory ALU instruction type?

(a) Data can be accessed without loading first.

(b) Fixed-length

(c) Simple code-generation

(d) Instructions take similar Clock Cycle per Instruction (CPI) to execute.

(e) Large variation in instruction size

register-register(load-store):ALU 只動 register,記憶體只經 load/store

(a) 要先 load 才能運算,與其他兩種相反 → F

(b) 運算元都是 register,指令長度固定 → T

(c) compiler 容易產生程式碼 → T

(d) 各指令的 CPI 相近,利於 pipeline → T

(e) 指令長度差異大是 memory operand 型態的缺點 → F

(b), (c), (d)

95 分

What are the properties critical to program correctness that are normally preserved by control dependency?

(a) Temporal locality

(b) Spatial locality

(c) Exception behavior

(d) Data flow

(e) None of the above

保持 control dependence 是為了保住兩個攸關正確性的性質:exception behavior 與 data flow

(a)(b) locality 是 cache 的性質,與 control dependence 無關 → F

(c)(d) → T

(c), (d)

105 分

What of the following statements are true?

(a) If some combination of instructions cannot be accommodated because of resource conflicts, the machine is said to have a structural hazard.

(b) The potential overlap among instructions is called Instruction-Level Parallelism.

(c) If there exists a loop-carried dependence, it is not possible to transform the code and unroll the loop to make iterations be executed in parallel.

(d) Hazards usually have smaller impact on longer pipelines.

(e) For a cache with write through strategy, read misses cannot result in writes.

(a) structural hazard 的定義 → T

(b) ILP 的定義 → T

(c) loop-carried dependence 不一定形成環,只要沒有 cycle 仍可轉換後平行 → F

(d) pipeline 越長,一次 hazard 暫停的 cycle 越多,影響越大 → F

(e) write-through 時 memory 永遠是新的,read miss 換出的 block 不必寫回 → T

(a), (b), (e)

115 分

Select the items which are needed to be supported by the operating system for handheld devices.

(a) Batch programming

(b) Virtual memory

(c) Time sharing

(d) Interrupt driving IO

(e) RAID

(a) batch 是大型主機時代的作業方式 → F

(b) 每個 app 有獨立位址空間、記憶體有限,靠 virtual memory 管理 → T

(c) 同時跑多個 app,靠 CPU 輪流使用(preemptive scheduling) → T

(d) 觸控、感測器、網路都是 interrupt driven I/O → T

(e) RAID 是伺服器的磁碟陣列 → F

這題改自 Silberschatz 第 1 章「handheld 與 real-time 各需要 batch、virtual memory、time sharing 哪些」的習題。早期版本的課文以 PDA 為例,說 handheld 記憶體小、多半一次只跑一個程式;本題以現行 handheld OS(Android、iOS)為準:有 virtual memory、多個 app 輪流用 CPU、I/O 以 interrupt 驅動。若只考慮早期一次跑一個程式的 PDA,(c) 可以不選

(b), (c), (d)

125 分

Which of the following components of program state are shared across threads in a multithreaded process?

(a) Register values

(b) Heap memory

(c) Global variables

(d) Stack memory

(e) Local variables

每個 thread 自己有:register(PC 等)、stack(local variable 放在 stack)

(a)(d)(e) → F

(b)(c) heap 與 global(data segment)全 thread 共用 → T

(b), (c)

135 分

Assume that a computer uses 32-bit addressing and has a 1MB cache with the block size equal to 32 bytes. The size of the Tag field in the address for a direct mapped cache is L. The size of the Tag field in the address for an 8 way set associative cache is M. The size of the Tag field in the address for a fully associative cache is N. L+M+N=K and

(a) K≤50 (b) 50≤K<55 (c) 55≤K<60 (d) 60≤K<65 (e) 65≤K

\(1\text{MB}/32\text{B}=2^{15}\) 個 block;offset \(=\log_2 32=5\) bits

direct mapped:index 15 bits → \(L=32-15-5=12\)

8-way:set 數 \(=2^{15}/8=2^{12}\),index 12 bits → \(M=32-12-5=15\)

fully associative:沒有 index → \(N=32-5=27\)

\(K=12+15+27=54\)

(b)

145 分

A cache with 64 blocks and a block size of 32 bytes. The byte address 2473537 maps to the block number \(K\) (\(0\le K\lt64\)). \(K\bmod5\) equals to?

(a) 0 (b) 1 (c) 2 (d) 3 (e) 4

block address \(=\lfloor2473537/32\rfloor=77298\)(\(32\times77298=2473536\))

\(K=77298\bmod64=77298-64\times1207=50\)

\(K\bmod5=50\bmod5=0\)

(a)

155 分

The following table shows the information about a machine executing instructions. There are 5 classes of instructions, each of which takes 3~5 steps.

Instruction ClassFetchRegister ReadALUMemory accessRegister Write
Load Word (LW)2ns1ns2ns3ns1ns
Store Word (SW)2ns1ns2ns3ns
R-Format (R)2ns1ns2ns1ns
Branch (B)2ns1ns2ns
Jump (J)2ns1ns2ns

For a certain program, 25% of the instructions are LW, 10% are SW, 45% are R, 15% are B, 5% are J. Consider the following three cases: (i) If there is no pipelining, the average time required for executing one instruction is L (ns). (ii) If a 5-stage pipeline is adopted, the average time required for executing one instruction in the ideal case is M (ns). (iii) Assume that the destinations of Branch (B) and Jump (J) will not be known until the end of the ALU stage. If every B or J instruction incurs two pipeline bubbles, the average time required for executing one instruction is N (ns). L+M+N=K. Then

(a) K<13 (b) 13≤K<14 (c) 14≤K<15 (d) 15≤K<16 (e) 16≤K

(i) no pipelining = single-cycle:clock 要容納最長的指令 LW,\(2+1+2+3+1=9\) ns,每個指令都花 9 ns → \(L=9\)

(ii) pipeline clock = 最慢的 stage = memory access 3 ns,ideal CPI \(=1\) → \(M=3\)

(iii) B、J 占 \(15\%+5\%=20\%\),各多 2 個 bubble:CPI \(=1+0.2\times2=1.4\) → \(N=1.4\times3=4.2\)

\(K=9+3+4.2=16.2\ge16\)

若把 L 讀成「每個指令只花自己用到的 stage 時間」的加權平均(6.75 ns),K=13.95;題目說「no pipelining」,本版取 single-cycle 的標準讀法

(e)

165 分

Which threading model is supported by the Linux operating system?

(a) one-to-many (b) many-to-one (c) one-to-one (d) many-to-many (e) none of the above

Linux 以 clone() 建立 thread,每個 user thread 對應一個 kernel thread → one-to-one

(c)

175 分

Suppose that there is a machine with 32-bit addresses and a two-level page table. Note that the first 10 bits of an address is an index into the first level page table and the next 10 bits are an index into a second level page table. The page tables are stored in memory and each entry in the page tables is 4 bytes. Suppose the space allocated to a specific process is 64 Mbytes. How many pages are occupied by this process?

(a) \(2^{26}\) pages (b) \(2^{14}\) pages (c) \(2^{12}\) pages (d) \(2^{10}\) pages (e) None of the above

位址 \(32-10-10=12\) bits 是 offset → page \(=2^{12}=4\) KB

\(64\text{ MB}/4\text{ KB}=2^{26}/2^{12}=2^{14}\) pages

(b)

185 分

(Continued from the previous question.) How much space is occupied in memory by the page tables for the specific process?

(a) 68 kbytes (b) 64 kbytes (c) 16 kbytes (d) 4 kbytes (e) None of the above

一張 second-level page table:\(2^{10}\) 個 entry \(\times4\) B \(=4\) KB,對應 \(2^{10}\) 個 page(4 MB)

\(2^{14}\) 個 page 需要 \(2^{14}/2^{10}=16\) 張 second-level table → \(16\times4=64\) KB

再加一張 first-level page table(\(2^{10}\times4=4\) KB)

\(64+4=68\) KB

(a)

195 分

Assume that an un-pipelined machine has 9ns clock cycles. The machine uses four cycles for ALU operations, four cycles for branches, and five cycles for memory operations. The relative frequencies of these operations are 30%, 20%, and 50%, respectively. Suppose that pipelining the machine adds 1ns of overhead to the clock cycle time. Assume that the ideal CPI is one. Ignore any other impact.

What is the average clock cycle per instruction (CPI) of the un-pipelined machine?

(a) 5.5 (b) 4 (c) 3.5 (d) 4.5 (e) 5

\(CPI=0.3\times4+0.2\times4+0.5\times5=1.2+0.8+2.5=4.5\)

(d)

205 分

(Continued from the previous question.) What is the speedup in the instruction execution rate gained from pipelining the machine?

(a) 4.05 (b) 4.75 (c) 5.15 (d) 5.85 (e) 6.28

un-pipelined:每個指令 \(4.5\times9=40.5\) ns

pipelined:clock \(=9+1=10\) ns,CPI \(=1\) → 每個指令 10 ns

speedup \(=40.5/10=4.05\)

(a)

109–115 的詳解也是這樣寫的。

國立中央大學 109–115 的詳解收錄在付費版;106–115 全年度完整詳解共 510 頁,逐題推導。

購買 · NT$ 850 看中央其他免費詳解

其他年度與考科

同一年的其他科

同一科的其他年度

聯絡我們

題目有錯、詳解看不懂,都歡迎來信

想許願補哪一份、對購買有疑問也可以,收到後會盡快回覆。

william.chou.123123@gmail.com