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

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

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

逐題詳解

14 分

Use 32-bit IEEE 754 single precision to encode "−1234.6875". If \(K\) is the number of "1" in this 32-bit value, then what is "\(K\bmod5\)"?

(A) 0 (B) 1 (C) 2 (D) 3 (E) 4

\(1234=10011010010_2\),\(0.6875=0.1011_2\)

\(1234.6875=10011010010.1011_2=1.0011010010\,1011\times2^{10}\)

sign \(=1\)(1 個 1);exponent \(=127+10=137=10001001_2\)(3 個 1)

fraction \(=0011010010\ 1011\ 000000000\)(23 bits):\(0011010010\) 有 4 個 1、\(1011\) 有 3 個 1,共 7 個

\(K=1+3+7=11\),\(11\bmod5=1\)

(B)

24 分

Assume that the number of data dependencies existing in the following MIPS code segment is \(K\). What is "\(K\bmod5\)"?

(A) 0 (B) 1 (C) 2 (D) 3 (E) 4

add $6, $4, $5
add $2, $5, $6
sub $3, $6, $4
add $2, $2, $3

data dependence = 後面指令讀前面指令寫入的暫存器(RAW)

指令 1 寫 \(\$6\) → 指令 2 讀 \(\$6\);指令 3 讀 \(\$6\)

指令 2 寫 \(\$2\) → 指令 4 讀 \(\$2\)

指令 3 寫 \(\$3\) → 指令 4 讀 \(\$3\)

共 4 個,\(K=4\),\(4\bmod5=4\)

指令 2 與 4 都寫 \(\$2\)(WAW,屬於 name dependence)若也算進去,\(K=5\),答案變 (A);這裡的 data dependence 只計 true dependence

(E)

34 分

Following the previous question. Assume that the code will be processed by the pipelined datapath shown below and assume that the registers initially contain their number plus 100. For example, $2 contains 102 and $5 contains 105, etc. In the fifth clock, calculate the sum of A, B, C, D, E, F and G. If this sum is equal to \(K\), what is "\(\{\text{Round}(K/3)\}\bmod5\)"? (原題附 pipelined datapath 圖:A、B 是 forwarding unit 從 ID/EX 讀入的 Rs、Rt;C、D 是 EX/MEM.Rd、MEM/WB.Rd;E、F 是 ALU 兩個輸入端 mux 的輸出;G 是 EX/MEM 的 ALU result)

(A) 0 (B) 1 (C) 2 (D) 3 (E) 4

clock12345
add $6,$4,$5IFIDEXMEMWB
add $2,$5,$6IFIDEXMEM
sub $3,$6,$4IFIDEX
add $2,$2,$3IFID

第 5 個 clock:EX 是 sub $3,$6,$4、MEM 是 add $2,$5,$6、WB 是 add $6,$4,$5

A、B = sub 的 Rs、Rt = \(6,\ 4\)

C = EX/MEM.Rd = 第二個 add 的 Rd = \(2\);D = MEM/WB.Rd = 第一個 add 的 Rd = \(6\)

E:sub 的 Rs \(=\$6\) 與 MEM/WB.Rd \(=6\) 相同(EX/MEM.Rd \(=2\ne6\)) → 從 MEM/WB forward \(\$6=\$4+\$5=104+105=209\)

F:Rt \(=\$4\) 無相依,直接用暫存器值 \(104\)

G:EX/MEM 的 ALU result = 第二個 add 的結果 \(\$5+\$6=105+209=314\)

\(K=6+4+2+6+209+104+314=645\);\(645/3=215\);\(215\bmod5=0\)

(A)

44 分

A system has a 256 Kbyte cache memory and the address format is: Tag(bit 31–14)|Set(bit 13–4)|Offset(bit 3–0). The cache should be

(A) 2-way set associative (B) 4-way set associative (C) 8-way set associative (D) a direct mapped cache (E) None of above.

offset \(=4\) bits → block \(=16\) B

set \(=10\) bits → \(1024\) 個 set

block 總數 \(=256\text{ KB}/16\text{ B}=16384\)

associativity \(=16384/1024=16\)-way,不在 (A)–(D) 裡

(E)

54 分

In a 3-level memory hierarchy system, the hit time for each level is \(T_1=10\) ns (L1-cache), \(T_2=200\) ns (L2-cache), \(T_3=600\) ns (Main memory). The local hit rate in each level is \(H_1=0.9\) (L1-cache), \(H_2=0.8\) (L2-cache), and \(H_3=1\). (It is assumed that we can always find the data in main memory.) If the average access time (in ns) of this memory system is \(K\). What is "\(\{\text{Round}(K\times123)\}\bmod5\)"?

(A) 0 (B) 1 (C) 2 (D) 3 (E) 4

\(K=T_1+(1-H_1)\bigl[T_2+(1-H_2)T_3\bigr]\)

\(=10+0.1\times(200+0.2\times600)=10+0.1\times320=42\) ns

\(42\times123=5166\);\(5166\bmod5=1\)

(B)

65 分

Suppose you want to perform the following executions: (a) 100 sums of scalar variables which can only be performed sequentially; (b) A matrix sum of a pair of two-dimensional arrays, size 1000 by 1000. What speedup do you get with 1000 processors (compared with only one processor)?

(A) 900 (B) 909 (C) 919 (D) 929 (E) 939

(a) 不能平行:100 次;(b) \(1000\times1000=10^6\) 次加法,可平行

1 個 processor:\(100+10^6=1{,}000{,}100\)

1000 個 processor:\(100+10^6/1000=1100\)

speedup \(=1000100/1100=909.2\approx909\)

(B)

75 分

Compute the clock cycle per instruction (CPI) for the following instruction mix. The mix includes 20% loads, 20% stores, 35% R-format operations, 20% branches, and 5% jumps. The number of clock cycles for each instruction class is listed as follows: 4 cycles for loads, 4 cycles for stores, 4 cycles for R-format instructions, 3 cycles for branches, 3 cycles for jumps.

(A) 3.15 (B) 3.25 (C) 3.5 (D) 3.75 (E) 3.9

\(CPI=0.2\cdot4+0.2\cdot4+0.35\cdot4+0.2\cdot3+0.05\cdot3=0.8+0.8+1.4+0.6+0.15=3.75\)

(D)

85 分

Which of the following statements are correct?

(A) The case of "TLB miss, Page Table hit, Cache hit" is possible.

(B) In a pipelined system, forwarding can eliminate all the data hazards.

(C) A write-through cache and a write-back cache will have the same miss rate.

(D) In the analysis using 3C miss model, a cache miss will be classified as one of the three types of misses, i.e. compulsory miss, conflict miss and capacity miss.

(E) Given a 32-bit long address, if a page size is 8K bytes, the virtual page number is of 19 bits long.

(A) TLB 沒有、page table 有(page 在 memory 裡)、資料在 cache → 可能 → T

(B) load-use hazard 即使 forwarding 也要 stall 一個 cycle → F

(C) miss rate 由 cache 大小、結構、替換決定,與寫入策略無關(同樣的 allocate 規則下) → T

(D) 3C:compulsory、capacity、conflict,每個 miss 屬於其中之一 → T

(E) 8 KB \(=2^{13}\),offset 13 bits → VPN \(=32-13=19\) bits → T

(A), (C), (D), (E)

95 分

For the C code A=B+C; Which of the following are correct.

(A) The accumulator style assembly would be: Load Address(B); Add Address(C); Store Address(A)

(B) The memory-to-memory style assembly code would be: Load R1, Address(B); Load R2, Address(C); Add R3, R1, R2; Store Address(A), R3

(C) The stack-style assembly would be: Push Address(A); Push Address(B); Add; Pop Address(C)

(D) The register-to-memory style assembly code would be: Load R1, Address(A); Add R2, R1, Address(B); Store Address(C), R2

(E) None of the above is correct.

(A) accumulator:Load B;Add C;Store A → T

(B) 這是 load-store(register-register)的寫法;memory-to-memory 一條指令 Add A, B, C → F

(C) stack:Push B;Push C;Add;Pop A (題目的 Push A、Push B、Pop C 算的是 C = A + B) → F

(D) register-memory:Load R1, B;Add R2, R1, C;Store A, R2(題目是 C = A + B) → F

(A)

105 分

What of the following statements are true?

(A) Using registers is more efficient for a compiler than other forms of internal storage.

(B) Load interlock can be resolved by forwarding hardware.

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

(D) Compilers can schedule the instructions to avoid unnecessary hazards

(E) None of the above

(A) register 讓 compiler 能自由安排運算順序,比 stack、accumulator 有效率 → T

(B) load-use 要 stall 一個 cycle(load interlock),forwarding 只能在 stall 之後轉送,無法單靠它消除 → F

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

(D) compiler 可重排指令避開 hazard → T

(A), (D)

115 分

Assume the following execution time for different operations: MUL takes 6 cycles, DIV takes 15 cycles, and ADD and SUB both take 1 cycle to complete. The instructions are issued into the pipeline in order, but out of order execution and completion is allowed. What hazards will be encountered when executing this code sequence?

MUL F1, F3, F2
ADD F2, F7, F8
DIV F10, F1, F5
SUB F5, F8, F2
SD  8(R1), F2

(A) No hazards for this code sequence

(B) There will be a data hazard when the ADD instruction is executed.

(C) There will be a data hazard when the SD instruction is executed

(D) There will be a data hazard when the DIV instruction is executed.

(E) A Write After Read (WAR) hazard is possible when SUB instruction completes execution.

(A) 下面 (D)(E) 成立 → F

(B) ADD 讀 F7、F8,前面沒有指令寫這兩個暫存器;它寫 F2 與 MUL 讀 F2 是 name dependence(WAR),不是 RAW 的 data hazard → F

(C) SD 要的 F2 由 ADD 產生,ADD 只要 1 cycle,SD 是第 5 個才 issue,值早已寫好 → F

(D) DIV 讀 F1,F1 要等 MUL 跑滿 6 cycle,DIV 是第 3 個 issue → RAW → T

(E) DIV 要 15 cycle 才讀完 F5 之後完成,SUB 只要 1 cycle,out-of-order completion 時 SUB 可能在 DIV 讀 F5 之前就寫掉 F5 → WAR → T

(D), (E)

125 分

Which of the following instructions should be sensitive in a VM executes native instructions?

(A) Set value of timer. (B) Read the clock. (C) Clear memory. (D) Issue a trap instruction. (E) Disable interrupts.

(A)(C)(E) 會影響整台機器的狀態 → sensitive → T

(B) 讀 clock 不改變機器狀態 → F

(D) trap 是 user program 呼叫 OS 的方式 → F

(A), (C), (E)

135 分

Consider the following segment table:

SegmentBaseLength
0219600
1230014
290100
31327580
4195296

What are the physical addresses reference in the following item will cause an illegal address trap to OS for the following logical addresses?

(A) 0,830 (B) 1,10 (C) 2,104 (D) 3,350 (E) 4,112

logical address \((s,d)\):\(d\ge\text{length}[s]\) 就會 trap

(A) \(830\ge600\) → trap → T

(B) \(10\lt14\) → \(2310\),合法 → F

(C) \(104\ge100\) → trap → T

(D) \(350\lt580\) → \(1677\),合法 → F

(E) \(112\ge96\) → trap → T

(A), (C), (E)

145 分

Consider a demand-paging system with the following time-measured utilizations: CPU utilization 20%, Paging disk 97.7%, Other I/O devices 5%. Which (if any) of the following will (probably) improve CPU utilization?

(A) Install a faster CPU.

(B) Install a bigger paging disk.

(C) Increase the degree of multiprogramming.

(D) Decrease the degree of multiprogramming.

(E) Install more main memory.

CPU 20%、paging disk 97.7% → thrashing

(A) CPU 不是瓶頸 → F

(B) disk 容量不影響換頁速度 → F

(C) 更多 process 搶 frame、page fault 更多 → F

(D) 少一點 process,working set 放得下 → T

(E) 記憶體加大、page fault 少 → T

(D), (E)

155 分

Spinlock synchronization schemes are "not" appropriate in which system?

(A) Single processor system (B) Multi core system (C) Multi-processor system (D) Multiple computer system (E) Real Time system

單一 CPU 上,拿著 lock 的 process 不可能在別的 CPU 執行;等 lock 的 process 空轉只是浪費 quantum,lock 持有者要等到被排程才能放掉

(B)(C) 多個 CPU 可讓持有者同時進行,spinlock 適合短的 critical section

(D) multiple computer 不共享記憶體,spinlock 根本不是它的同步方式(用 message passing)

單選題取最典型的 (A)

(A)

165 分

Which of the following programming techniques and structures are good for a demand-paged environment?

(A) Stack (B) Hashed symbol table (C) Sequential search (D) Binary search (E) pure code

(A) stack 的存取集中在頂端,locality 好 → T

(B) hash 把存取散在整個表,locality 差 → F

(C) 循序搜尋依序走過,locality 好 → T

(D) binary search 每次跳到很遠的位置 → F

(E) pure code(reentrant)不會被修改,換出時不必寫回,可多個 process 共用 → T

(A), (C), (E)

175 分

A program initializes a global variable X to zero, and spawns three threads. Each of the three threads reads X, increases it by one, and then stores the result back. What are the possible values of X when all threads terminate?

(A) X=0. (B) X=1. (C) X=2. (D) X=3. (E) None of the above.

每個 thread 都做 read、+1、store;沒有同步,三者交錯(race condition)

(A) 至少最後一個 store 的 thread 寫入 \(\ge1\) → 不可能 0 → F

(B) 三個都先 read 到 0,再依序 store 1 → X=1 → T

(C) 兩個 read 到 0 都 store 1,另一個在之後 read 1 store 2 → X=2 → T

(D) 依序執行 → X=3 → T

(B), (C), (D)

185 分

Choose the correct statements from the multiple choices regarding context switching.

(A) Context switch time is independent of hardware support.

(B) Switching between threads of a single process is faster than switching between two separate processes.

(C) A spinlock will ultimately result in a context switch when a process must wait on a lock.

(D) Context of a process is represented in the PCB.

(E) None of the above.

(A) 暫存器組數量、記憶體速度等硬體支援會影響切換時間 → F

(B) 同一個 process 的 thread 共用位址空間,不必切換 page table/TLB → T

(C) spinlock 是 busy waiting,不主動 context switch → F

(D) process 的 context 存在 PCB → T

(B), (D)

195 分

Choose the correct statements from the multiple choices regarding deadlock.

(A) If the resource allocation graph contains a cycle, a deadlock exists.

(B) Banker's algorithm for resource allocation deals with deadlock avoidance.

(C) There are no deadlocks if the system is in safe state.

(D) Process termination is used for deadlock prevention.

(E) None of the above.

(A) 資源有多個 instance 時,有 cycle 不一定 deadlock → F

(B) banker's algorithm 是 deadlock avoidance → T

(C) safe state 一定沒有 deadlock → T

(D) 終止 process 屬於 deadlock recovery → F

(B), (C)

205 分

Choose the correct statements from the multiple choices regarding Linux.

(A) atd is the daemon that deals with command to be executed a single time.

(B) cron is the daemon responsible for executing scheduled and recurring commands.

(C) init is the parent of all processes.

(D) systemd allows more processing to be done concurrently or in parallel during system booting.

(E) None of the above.

(A) atd:只執行一次的排程 → T

(B) cron:週期性排程 → T

(C) init(PID 1)是所有 process 的祖先 → T

(D) systemd 平行啟動服務 → T

(A), (B), (C), (D)

215 分

Choose the correct statements from the multiple choices regarding IPv6.

(A) In IPv6, routers are not allowed to fragment packets.

(B) Fragment header does not exist in IPv6 protocol.

(C) IPv6 does not support Anycast.

(D) 2001:D88:2de::e13 is a legal IPv6 address.

(E) None of the above.

(A) IPv6 只有來源端可以分片,router 不分片 → T

(B) Fragment header 是 IPv6 的 extension header(來源端分片時用) → F

(C) IPv6 有 anycast address → F

(D) 2001:0D88:02de:0000:0000:0000:0000:0e13,合法縮寫 → T

(A), (D)

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

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

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

其他年度與考科

同一年的其他科

同一科的其他年度

聯絡我們

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

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

william.chou.123123@gmail.com