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

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

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

逐題詳解

14 分

The information of a virtual memory system is assumed to be: Page size: 1024 words; Number of virtual pages: 8; Number of physical pages: 4; The current page table is

VPN01234567
PPN21NULLNULL3NULL0NULL

For the following (decimal) virtual word addresses: VA1: 57, VA2: 2048, VA3: 1026, VA4: 7749, VA5: 6150, their corresponding physical addresses are PA1, PA2, PA3, PA4, PA5. \(K=(PA1+PA2+PA3+PA4+PA5)\bmod5\), where "mod" is the modulo operator, and PA = −1 if it is a page fault. What is "K"?

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

\(\text{VPN}=\lfloor VA/1024\rfloor\),offset \(=VA\bmod1024\),\(PA=PPN\times1024+\text{offset}\)

VA1 \(=57\):VPN 0 \(\to\) PPN 2 → \(PA1=2048+57=2105\)

VA2 \(=2048\):VPN 2 \(\to\) NULL → \(PA2=-1\)

VA3 \(=1026\):VPN 1、offset 2 \(\to\) PPN 1 → \(PA3=1024+2=1026\)

VA4 \(=7749\):VPN 7 \(\to\) NULL → \(PA4=-1\)

VA5 \(=6150\):VPN 6、offset 6 \(\to\) PPN 0 → \(PA5=0+6=6\)

\(2105-1+1026-1+6=3135\),\(3135\bmod5=0\)

(A)

24 分

A cache with data size 1 Mbytes contains 32768 blocks and is eight-way set associative. The byte address 0x11D9A4F1 is accessed and is a hit in this cache. Assume that the corresponding tag value is "T", what is "T mod 5"?

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

block \(=1\text{ MB}/32768=32\) B → offset 5 bits

set 數 \(=32768/8=4096=2^{12}\) → index 12 bits

tag \(=32-12-5=15\) bits

\(\text{0x11D9A4F1}=0001\ 0001\ 1101\ 1001\ 1010\ 0100\ 1111\ 0001_2\)

去掉低 17 bits(offset 5+index 12):\(\text{0x11D9A4F1}\gg17=\text{0x8EC}=2284\)

\(T=2284\),\(2284\bmod5=4\)

(E)

34 分

Given a function or output F with four inputs: A, B, C, D as \(F(A,B,C,D)=\sum(3,4,5,6,7)\) (minterms) and its don't care information is \(d(A,B,C,D)=\sum(10,11,14,15)\). By the commonly used Karnaugh Map, simplify F with the minimum number of gates using "product of sum" and there are "M" OR gates, "N" AND gates, "P" NOT/INVERT gates, where each AND/OR gate has two inputs and NOT gate has one input. \(K=(M\times4+N\times3+P)\bmod5\). What is "K"?

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

POS 要圈 \(F=0\) 的格子:\(F=0\) 在 \(0,1,2,8,9,12,13\)(don't care \(10,11,14,15\) 可圈可不圈)

AB\CD00011110
000010
011111
1100XX
1000XX

圈 0 的群組(don't care 可一起圈進來,群組越大越好):

\(A=1\) 的 8 格(\(8,9,12,13\) 是 0,\(10,11,14,15\) 是 X)可整組圈成一個 8 格的群組 → \(A\)

剩下 \(A=0\) 的 0 在 \(0,1,2\):\(\{0,1,8,9\}=\bar B\bar C\)、\(\{0,2,8,10\}=\bar B\bar D\)(\(0,1,2\) 三格湊不成一個群組,因為 \(3\) 是 1)

\(F'=A+\bar B\bar C+\bar B\bar D\) → \(F=\bar A\,(B+C)(B+D)\)

\(B+C\)、\(B+D\) 各一個 OR → \(M=2\);\(\bar A\) 要一個 NOT → \(P=1\);三項相乘用 2 個兩輸入 AND → \(N=2\)

\(K=(2\times4+2\times3+1)\bmod5=15\bmod5=0\)

只圈 \(\{8,9,12,13\}\) 會得到 \(F=(B+D)(B+C)(\bar A+C)\)(3 OR、2 AND、1 NOT,\(K=4\)),比較不簡;若改成 sum of products,最簡是 \(F=\bar AB+CD\)(1 OR、2 AND、1 NOT),\(K=(4+6+1)\bmod5=1\)。題目要求 product of sum,答 \(K=0\)

(A)

44 分

"M" is a floating-point number in the format of IEEE754 single precision: 01000000001010101010101010101010. \(K=\{\text{Round}(M\times20)\}\bmod5\). What is K?

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

sign \(=0\);exponent \(=10000000_2=128\) → \(2^{128-127}=2\)

fraction \(=01010101010101010101010_2\)(共 23 bits,第 2、4、…、22 位是 1,共 11 個)

\(1.f=1+\sum_{k=1}^{11}4^{-k}=1+\tfrac13(1-4^{-11})\approx1.33333\)

\(M\approx2\times1.33333=2.66667\);\(M\times20\approx53.33\) → Round \(=53\)

\(53\bmod5=3\)

(D)

54 分

There are three classes of instructions: Class A, Class B and Class C. The CPI values for Classes A, B and C are 3, 2 and 1 respectively. We have two compilers, C1 and C2. The compiler C1 generates \(10^6\) Class A instructions, \(2\times10^6\) class B instructions and \(5\times10^6\) Class C instructions. The compiler C2 generates \(10^6\) class A instructions, \(10^6\) Class B instructions and \(10^7\) Class C instructions. If C1 is tested on a 1GHz machine, M1, while C2 is tested on a 1.5GHz machine, M2, the execution time of {C1, M1} is "T1" ms (milliseconds) while the execution time of {C2, M2} is "T2" (milliseconds). Calculate \(K=\{\text{Round}(|T1-T2|\times1234)\}\bmod5\).

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

C1:cycles \(=3\cdot10^6+2\cdot2\cdot10^6+1\cdot5\cdot10^6=12\times10^6\);1 GHz → \(T1=12\) ms

C2:cycles \(=3\cdot10^6+2\cdot10^6+10^7=15\times10^6\);1.5 GHz → \(T2=10\) ms

\(|T1-T2|=2\);\(2\times1234=2468\) → \(2468\bmod5=3\)

(D)

65 分

Which of the following statements are true?

(A) Page table is a cache.

(B) TLB is a cache.

(C) "TLB miss, Page table hit, Cache miss" is possible.

(D) Conflict misses only occur in a direct-mapped or set-associative cache and can be eliminated in a fully associative cache of the same size.

(E) A very large cache can avoid all the misses.

(A) page table 存的是完整的位址對應(在 main memory),不是 cache;TLB 才是 page table 的 cache → F

(B) TLB 快取 page table 的 entry → T

(C) TLB miss 後在 page table 找到,之後資料不在 cache → 可能 → T

(D) conflict miss 來自多個 block 對到同一個 set;fully associative 沒有 set 限制,同大小時消除 → T

(E) 第一次存取一定 miss(compulsory miss),再大的 cache 也避不掉 → F

(B), (C), (D)

75 分

Which are the causes that limit the growth of uniprocessor performance and motive the trend of developing multiple processors per chip in recent years?

(A) Long memory latency

(B) Emergence of Reduced Instruction Set Computer

(C) Limits of power

(D) Little instruction-level parallelism left to exploit efficiently

(E) None of the above

(A) memory wall → T

(B) RISC 反而是提升效能的方法 → F

(C) power wall → T

(D) ILP wall → T

(A), (C), (D)

85 分

Suppose that the frequency of Floating Point (FP) operations is 25% and the average Clock Cycle Per Instruction (CPI) of FP operations is 4. The frequency of Floating Point Square Root (FPSQR) operations is 2% and the average Clock Cycle Per Instruction (CPI) of FPSQR operations is 20. The average CPI of other instructions is 1.33. There are two alternatives to improve the processor. Alternative 1 is to reduce the CPI of FPSQR to 2. Alternative 2 is to reduce the average CPI of all FP to 2. Which of the following is true?

(A) Alternative 1 is better.

(B) Alternative 2 is better.

(C) The CPI of alternative 1 is 1.25.

(D) The CPI of alternative 2 is 1.25.

(E) The speedup for alternative 2 is 1.33.

FPSQR 是 FP 的一部分。原本 \(CPI=0.25\times4+0.75\times1.33=1.0+0.9975\approx2.0\)

Alt 1:\(CPI=2.0-0.02\times(20-2)=1.64\)

Alt 2:\(CPI=0.25\times2+0.75\times1.33=0.5+0.9975\approx1.5\)

(A) F (B) T(\(1.5\lt1.64\)) (C) 1.64 不是 1.25 → F (D) 1.5 不是 1.25 → F

(E) \(2.0/1.5\approx1.33\) → T

(B), (E)

95 分

Which of the following statements are true for General-purpose register (GPR) instruction architecture?

(A) One of the advantages of register-register instructions is simpler code-generation.

(B) The instruction count for register-register instructions is usually lower than register-memory instructions.

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

(D) When variables are allocated to registers, the memory traffic reduces, the program speeds up.

(E) None of the above

(A) 運算元只在 register,code generation 單純 → T

(B) register-register 需要額外的 load/store,指令數通常比 register-memory 多 → F

(C) register 讓 compiler 能自由安排運算順序(stack、accumulator 受限) → T

(D) 變數放在 register,記憶體存取變少、速度變快 → T

(A), (C), (D)

105 分

About single-cycle implementation and multi-cycle implementation of control and data path, which of the following statements are true?

(A) Single-cycle implementation of control and data path is better than multi-cycle implementation.

(B) Multi-cycle implementation of control and data path prevents an instruction from sharing functional units with another instruction within the execution of the instruction.

(C) Single-cycle implementation facilitates the design of pipeline.

(D) For multi-cycle implementation, the clock cycle is determined by the longest possible path.

(E) None of the above.

(A) 兩種各有取捨(clock、CPI、硬體成本),不能說誰比較好 → F

(B) multi-cycle 不 pipeline,一條指令做完才開始下一條,不會有兩條指令同時共用 functional unit → T

(C) pipeline 是把 single-cycle datapath 切成 stage → T

(D) multi-cycle 的 clock 由各步驟中最長的 path(最慢的 step)決定 → T

(B), (C), (D)

115 分

Considering the following code sequence.

1  Loop: LD    F0, 0(R1)
2        SUBI  R1, R1, 8
3        ADDD  F4, F0, F2
4        stall
5        BNEZ  R1, Loop
6        SD    8(R1), F4

Unroll four times and rearrange the code to minimize the stalls

1  Loop: LD    F0, 0(R1)
2        LD    F6, -8(R1)
3        LD    F10, -16(R1)
4        LD    F14, -24(R1)
5        ADDD  F4, F0, F2
6        ADDD  F8, F6, F2
7        ADDD  F12, F10, F2
8        ADDD  F16, F14, F2
9        SD    0(R1), F4
10       SD    -8(R1), F8
11       SUBI  R1, R1, #32
12       SD    A(R1), F12
13       BNEZ  R1, LOOP
14       SD    B(R1), F16

Where A and B stand for two numbers. Which of the following is true.

(A) Number A in line 12 should be 8. (B) Number A in line 12 should be 16. (C) Number B in line 14 should be 8. (D) Number B in line 14 should be 16. (E) Number B in line 14 should be 32.

F12 的資料是 \(R1_{old}-16\) 的那筆(LD F10, −16(R1));F16 是 \(R1_{old}-24\)

第 11 行把 R1 減 32:\(R1_{new}=R1_{old}-32\)

line 12:\(R1_{old}-16=R1_{new}+16\) → \(A=16\)

line 14:\(R1_{old}-24=R1_{new}+8\) → \(B=8\)

(A) F (B) T (C) T (D) F (E) F

(B), (C)

125 分

Which of the following instructions should be privileged?

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

(A)(C)(E) 會影響整機的保護與排程 → privileged → T

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

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

(A), (C), (E)

135 分

Identify the following environments need hard real-time scheduling.

(A) Thermostat in a household. (B) Control system for a nuclear power plant. (C) Fuel economy system in an automobile. (D) Landing system in a jet airliner. (E) Mailing system.

hard real-time:錯過 deadline 就是嚴重失敗

(A) 偶爾慢一點無傷 → F

(B) 核電廠控制 → T

(C) 影響的是效率,非安全 → F

(D) 降落系統 → T

(E) F

(B), (D)

145 分

Consider the following code segment:

pid_t pid;
pid = fork();
if (pid == 0) { /* child process */
  fork();
  thread_create(...);
}
fork();

a. How many unique processes are created? and b. How many unique threads are created? Please select the correct answer:

(A) two processes (B) four processes (C) six processes (D) two threads (E) four threads

P0 做第一次 fork → 得 child C1

C1(pid==0)再 fork → 得 C2;C1 與 C2 各呼叫一次 thread_create → 共 2 個 thread

最後一個 fork() 在 if 外面,P0、C1、C2 三個 process 都會執行 → 再得 3 個新 process

process 總共:P0、C1、C2 與 3 個新的 → 6 個;thread:2 個(fork 出來的 process 只複製呼叫者,不含別的 thread)

(C), (D)

155 分

Consider the following segment table:

Segment01234
Base21923009013271952
Length6001410058096

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,430 (B) 1,10 (C) 2,500 (D) 3,400 (E) 4,112

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

(A) \(430\lt600\) → \(219+430=649\),合法 → F

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

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

(D) \(400\lt580\) → \(1727\),合法 → F

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

(C), (E)

165 分

Which of the following scheduling algorithms could result in starvation?

(A) First-come, first-served (B) Shortest job first (C) Round robin (D) Priority (E) None

(A) 依到達順序 → F

(B) 長工作一直被短工作插隊 → T

(C) 輪流 → F

(D) 低 priority 可能一直等不到 → T

(B), (D)

175 分

Choose the correct statements from the multiple choices regarding DMA.

(A) DMA is a mechanism for allowing an I/O device to transfer data to and from memory without involving the CPU in the transfer.

(B) In DMA only one interrupt is generated per byte.

(C) While the DMA controller is performing the data transfer, the CPU is free to perform other tasks.

(D) The cycle stealing in DMA can speed up the CPU computation.

(E) DMA can perform a transfer between two memory-mapped devices without the intervention of the CPU or the use of main memory.

(A) DMA 的定義 → T

(B) 每搬完一個 block 才發一次 interrupt → F

(C) 搬資料期間 CPU 可做別的事 → T

(D) cycle stealing 是 DMA 搶 memory bus 的 cycle,CPU 會被拖慢 → F

(E) direct virtual-memory access(DVMA)可在兩個 memory-mapped device 間傳輸,不經 CPU 與 main memory → T

(A), (C), (E)

185 分

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

(A) A context switch from one process to another can be accomplished without executing OS code in kernel mode.

(B) Paging increases the context-switch time.

(C) Network traffic can cause a high context-switch rate.

(D) The smaller the time quantum in RR scheduling, the more context switches.

(E) None of the above.

(A) 存取 PCB、切換 page table 都要在 kernel mode 執行 OS code → F

(B) 還要切換 page table(TLB 也要處理) → T

(C) 大量封包帶來大量 interrupt 與要處理的 task → T

(D) quantum 越小,切換越頻繁 → T

(B), (C), (D)

195 分

Choose the correct statements from the multiple choices regarding deadlock.

(A) Deadlock prevention requires that the operating system is given in advance additional information concerning which resources a process will request and use during its lifetime.

(B) If a resource-allocation graph has a cycle, the system is in a deadlock state.

(C) An unsafe state means the system is in deadlock.

(D) Deadlock can never occur if no process is allowed to hold a resource while requesting another resource.

(E) To deal with deadlocks, most operating systems, including UNIX, pretend that deadlocks never occur in the system.

(A) 要事先知道資源需求的是 deadlock avoidance(banker's algorithm),不是 prevention → F

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

(C) unsafe 只是「可能」deadlock → F

(D) 破壞 hold and wait → 不會 deadlock → T

(E) ostrich algorithm → T

(D), (E)

205 分

Choose the correct statements from the multiple choices regarding policies and mechanisms.

(A) Policies decide how to do something.

(B) Policies are likely to change from place to place or time to time.

(C) "How long the timer for CPU protection is set for a particular user" is a mechanism.

(D) "What the punishments are if the procedures are not followed" is a policy decision.

(E) Firewall is a mechanism for access restriction.

(A) policy 決定「做什麼」,mechanism 決定「怎麼做」 → F

(B) policy 會隨地點、時間改變 → T

(C) timer 這個機制是 mechanism,但「設多久」是 policy → F

(D) 處分方式是 policy → T

(E) firewall 實現存取限制 → T

(B), (D), (E)

215 分

Choose the correct statements from the multiple choices regarding ICMP and OSPF.

(A) The traceroute command can be implemented by ICMP messages.

(B) The ping utility can be implemented by ICMP messages.

(C) OSPF is based on Dijkstra's algorithm.

(D) OSPF is a kind of distance-vector routing protocols.

(E) OSPF is a kind of exterior gateway protocols.

(A) traceroute 用 TTL 逾時的 ICMP Time Exceeded → T

(B) ping 用 ICMP echo request/reply → T

(C) OSPF 是 link-state,各 router 以 Dijkstra 算最短路 → T

(D) OSPF 是 link-state,不是 distance-vector → F

(E) OSPF 是 interior gateway protocol(IGP) → F

(A), (B), (C)

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

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

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

其他年度與考科

同一年的其他科

同一科的其他年度

聯絡我們

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

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

william.chou.123123@gmail.com