109 年 國立陽明交通大學資訊工程學系碩士班《計算機系統》

第 1 題4 分

Which one(s) of the following statements about modern operating systems are correct?

(A) Microkernels can suffer from performance decreases due to overhead of user space to kernel space communication.
(B) To create and use shared memory, several system calls have to be invoked.
(C) Direct Memory Access (DMA) can reduce the number of interrupts for data transmission.
(D) None of the above statements is correct.

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

這一題的完整詳解

核心觀念

本題考查微核心架構、共享記憶體的系統呼叫,以及直接記憶體存取(DMA)如何影響資料傳輸效率與中斷次數。

  • 微核心將較多作業系統服務移到使用者空間執行。使用者程式與服務之間需要透過核心進行訊息傳遞,因此跨越使用者空間與核心空間的切換及通訊成本,可能降低效能。
  • 共享記憶體需要作業系統建立並映射共享區域,讓不同程序能存取同一段記憶體。建立與使用時通常需要呼叫多個系統呼叫。
  • DMA讓裝置控制器直接在裝置與主記憶體之間傳送資料,降低 CPU 逐筆搬移資料的負擔,也能減少 CPU 必須處理的中斷次數。

解題方法

逐項判斷各敘述是否符合其機制。特別要區分:DMA 並非完全不使用中斷,而是能讓 CPU 不必因每個資料單位都介入處理;共享記憶體也不是只靠「宣告一塊記憶體」就能讓多個程序共同存取,仍須經作業系統建立與映射。

選項分析

🔒

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

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

免費註冊

第 2 題4 分

Which one(s) of the following statements about processes and threads are correct?

(A) Threads created by a process do not share their program counters.
(B) After the exec() system call is applied, the process ID is not changed.
(C) When a process issues a blocking I/O request, it will be moved to the ready queue.
(D) A process can be removed forcibly from the CPU (running state) as a result of an interrupt.

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

這一題的完整詳解

核心觀念

程序(process)是資源分配的單位;執行緒(thread)是 CPU 排程與執行的單位。同一程序中的執行緒共享程式碼、資料與開啟的檔案等資源,但各自保有程式計數器(program counter)、暫存器與堆疊。

程序常見狀態包括:

  • 執行中(running):正在 CPU 上執行。
  • 就緒(ready):已具備執行條件,等待 CPU。
  • 等待/阻塞(waiting/blocked):等待 I/O 或其他事件完成。

判斷時要分清楚「等待 CPU」與「等待事件」:前者在就緒佇列,後者在等待狀態。

解題方法

逐一檢查各敘述是否符合程序與執行緒的定義,以及程序狀態轉換規則:

  • 看執行緒是否各自有獨立的執行狀態。
  • 看 exec() 是否建立新程序,或是在原程序中載入新程式。
  • 看阻塞 I/O 等待的是 CPU,還是 I/O 完成。
  • 看中斷是否能讓目前正在執行的程序離開 CPU。

選項分析

🔒

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

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

免費註冊
📄 以下 1 題共用同一段題幹

Assume that a system issues multiple producer and consumer processes for a shared buffer (size n=5n=5), using semaphores empty, mutex, and full.

A producer process:

do {
    ...
    // produce an item in nextp
    ... // Section PA
    wait(empty);
    ... // Section PB
    wait(mutex);
    ... // Section PC
    // add nextp to buffer
    ... // Section PD
    signal(mutex);
    ... // Section PE
    signal(full);
} while (TRUE);

A consumer process:

do {
    wait(full);
    ... // Section CA
    wait(mutex);
    ... // Section CB
    // remove an item from buffer to nextc
    ... // Section CC
    signal(mutex);
    ... // Section CD
    signal(empty);
    ... // Section CE
    // consume the item in nextc
    ...
} while (TRUE);

第 3 題4 分

Which of the following statements are correct?

(A) The semaphore empty should be initialized to 00.
(B) Up to one consumer process can enter “Section CA” (between wait(full) and wait(mutex)) at a time.
(C) When there are only one producer process and one consumer process, the binary semaphore mutex is redundant.
(D) None of the above statements is correct.

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

這一題的完整詳解

核心觀念

本題考查有限緩衝區中的計數型信號量與互斥信號量:

  • empty 計算空槽數,初值為緩衝區大小 n=5n=5。
  • full 計算已填入項目的數量,初值為 00。
  • mutex 保護緩衝區的共享資料結構,通常設為 11。

生產者取得一個空槽後才能放入項目;消費者取得一個已填入項目後才能取出。互斥信號量則用來避免多個執行緒同時更新共享緩衝區。

解題方法

逐一檢查各選項:先判斷信號量的初值,再看哪些執行緒能通過計數信號量進入指定區段,最後分析只有一個生產者與一個消費者時,緩衝區操作是否仍需要互斥保護。

選項分析

(A) 錯誤。
empty 表示空槽數。緩衝區一開始有 55 個空槽,因此初值應為 55,不是 00。

(B) 錯誤。
full 是計數型信號量。每個消費者通過 wait(full) 後,都會把計數值減少 11;

🔒

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

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

免費註冊

第 4 題4 分

Consider a system with four processes P1∼P4P_1\sim P_4 and three resource types A, B, and C. Suppose that at time T0T_0, the resource allocation state is:

ProcessAllocation (A, B, C)MAX (A, B, C)
P1P_1(2,0,1)(2,0,1)(2,0,3)(2,0,3)
P2P_2(0,1,1)(0,1,1)(1,2,1)(1,2,1)
P3P_3(1,1,0)(1,1,0)(1,1,3)(1,1,3)
P4P_4(1,0,2)(1,0,2)(2,1,2)(2,1,2)
P5P_5(1,1,0)(1,1,0)(1,2,0)(1,2,0)

Available resources are (1,0,2)(1,0,2) for (A,B,C)(A,B,C).

Which of the following statements are correct?

(A) ⟨P4,P1,P2,P3,P5⟩\langle P_4,P_1,P_2,P_3,P_5\rangle is a safe sequence.
(B) ⟨P1,P3,P5,P4,P2⟩\langle P_1,P_3,P_5,P_4,P_2\rangle is a safe sequence.
(C) Operating systems have to estimate the MAX value when a process enters the ready queue.
(D) None of the above statements is correct.

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

這一題的完整詳解

核心觀念

本題考 銀行家演算法(Banker’s algorithm) 中的安全狀態與安全序列。

每個行程尚需的資源量為:

Need=MAX−Allocation\text{Need}=\text{MAX}-\text{Allocation}

判斷安全序列時,從目前的 Available 開始,依序檢查每個行程的 Need 是否逐項小於或等於目前可用資源。若符合,便假設該行程完成,將它已持有的 Allocation 歸還,再檢查下一個行程。若所有行程都能依序完成,該順序就是安全序列。

題幹開頭提到四個行程,但表格列出 P1P_1 至 P5P_5;以下依表格中的五個行程計算。

解題方法

先計算各行程的 Need:

行程Need (A, B, C)
P1P_1(2,0,3)−(2,0,1)=(0,0,2)(2,0,3)-(2,0,1)=(0,0,2)
P2P_2(1,2,1)−(0,1,1)=(1,1,0)(1,2,1)-(0,1,1)=(1,1,0)
P3P_3(1,1,3)−(1,1,0)=(0,0,3)(1,1,3)-(1,1,0)=(0,0,3)
P4P_4(2,1,2)−(1,0,2)=(1,1,0)(2,1,2)-(1,0,2)=(1,1,0)
P5P_5(1,2,0)−(1,1,0)=(0,1,0)(1,2,0)-(1,1,0)=(0,1,0)

初始可用資源為 (1,0,2)(1,0,2)。

檢查選項 (B) 的順序:

🔒

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

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

免費註冊
📄 以下 1 題共用同一段題幹

Consider the following code using pthread:

... // include header files

void func(void *ptr);
sem_t mutex;
int m;

int main() {
    int i;
    int n;
    int p[3];
    pthread_t thrd[3];

    m = 0;
    n = 0;
    p[0] = 0; // argument to threads
    p[1] = 1;
    p[2] = 2;
    sem_init(&mutex, 0, 1); // initialize mutex to 1

    for (i = 0; i < 3; i++)
        pthread_create(&thrd[i], NULL, (void *)&func, (void *)&p[i]);

    for (i = 0; i < 3; i++)
        pthread_join(thrd[i], NULL);

    sem_destroy(&mutex); // destroy semaphore
    exit(0);
} // main()

void func(void *ptr) {
    int a, n = 0;
    a = *((int *)ptr);
    sem_wait(&mutex);
    m++;
    printf("m = %d\\n", m);
    sem_post(&mutex);

    n = a;
    printf("n= %d\\n", n);

    pthread_exit(0);
} // func()

第 5 題4 分

Which of the following statements about executing this program are correct?

(A) A race condition does not occur.
(B) The sum of all output numbers is less than 77.
(C) The executed program outputs the number “2” at most once.
(D) All performed func calls share the content of variable m.

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

這一題的完整詳解

核心觀念

本題考查 pthread 執行緒的共享變數、區域變數與競爭條件(race condition)。

  • m 宣告在函式外,是所有執行緒共用的全域變數。
  • func 裡的 n 是區域變數,每次呼叫都有自己的副本;它也遮蔽了 main 裡的 n。
  • sem_wait(&mutex) 與 sem_post(&mutex) 將對 m 的遞增和輸出包在臨界區內。信號量初值為 11,因此同一時間只有一個執行緒能進入臨界區。

解題方法

每個執行緒收到不同的陣列元素位址,讀出參數 aa 後,先鎖定信號量,再將共用的 m 加 11 並輸出;解鎖後,才將自己的區域變數 n 設為 aa 並輸出。

關鍵程式如下:

sem_wait(&mutex);
m++;
printf("m = %d\n", m);
sem_post(&mutex);

n = a;
printf("n= %d\n", n);

三個執行緒對 m 的更新受到信號量保護,因此 m 依序輸出 1,2,31,2,3。各執行緒的 a 分別為 0,1,20,1,2,所以各自輸出的 n 值為 0,1,20,1,2。兩類輸出行的先後順序可能交錯,但數值集合固定。

輸出的數字總和為

(1+2+3)+(0+1+2)=6+3=9(1+2+3)+(0+1+2)=6+3=9

執行緒數量固定為 33,時間複雜度為 O(1)O(1),額外空間複雜度為 O(1)O(1)。

選項分析

🔒

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

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

免費註冊

第 6 題4 分

Which one(s) of the following statements about stack and heap are correct?

(A) Memory blocks on the stack can be freed at any time.
(B) Memory blocks on the heap can be freed at any time.
(C) Typically, each thread has its own stack.
(D) Typically, each thread has its own heap.

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

這一題的完整詳解

核心觀念

這題考查程序執行時的記憶體配置,以及堆疊與堆積的生命週期管理方式。

  • 堆疊(stack):通常以後進先出(LIFO)的方式管理,函式呼叫時建立堆疊框架,函式返回時依序釋放。
  • 堆積(heap):由程式在執行期間動態配置記憶體,配置區塊可由程式明確釋放;區塊不必按照配置的先後順序釋放。
  • 執行緒與記憶體:同一程序中的每個執行緒通常有自己的堆疊;程序中的執行緒通常共用同一個堆積。

解題方法

逐項判斷兩件事:記憶體區塊能否任意時點釋放,以及該記憶體區域是每個執行緒各自擁有,還是由程序內執行緒共用。堆疊受到 LIFO 順序限制;堆積則可由程式選擇釋放時機。

選項分析

🔒

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

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

免費註冊

第 7 題4 分

Given four hard disks with equal capacity, if we want to assemble a RAID (Redundant Array of Inexpensive Disks) to tolerate a single disk failure, which of the following configurations would suffice?

(A) RAID 0.
(B) RAID 1.
(C) RAID 1+0.
(D) RAID 5.

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

這一題的完整詳解

核心觀念

RAID 的容錯能力取決於資料是否有冗餘:

  • RAID 0 只分散資料,沒有備份或同位元資訊;任一磁碟故障都會使陣列資料不完整。
  • RAID 1 以鏡像方式在多顆磁碟上保存相同資料;只要仍有一份副本可用,就能承受磁碟故障。
  • RAID 1+0(RAID 10) 先做鏡像,再跨鏡像組分散資料;任一單顆磁碟故障時,其鏡像副本仍可提供資料。
  • RAID 5 以分散式同位元資訊提供冗餘;四顆磁碟中有一顆故障時,可由其餘磁碟的資料與同位元資訊重建內容。

解題方法

逐一檢查每種配置是否包含足以復原資料的冗餘。題目要求容忍「單一磁碟故障」,因此只要一顆磁碟故障後仍能讀取資料,便符合條件。

選項分析

🔒

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

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

免費註冊

第 8 題4 分

Which of the following are true about the use of page tables in virtual memory management?

(A) Each user process has its own virtual address space by default.
(B) The page table of a Linux process is managed by the C runtime library in the process (e.g., libc-x.xx.so).
(C) Use of shared memory can reduce the number of page table entries in a page table.
(D) For unused regions in the virtual address space, the space overhead of the corresponding page table entries can be negligible.

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

這一題的完整詳解

核心觀念

每個行程通常都有自己的虛擬位址空間。頁表由作業系統核心管理,負責把虛擬頁面對應到實體頁框,並記錄存取權限等資訊。

多層頁表會按需配置頁表結構:沒有使用到的虛擬位址範圍,通常不必為每一頁都配置實際的頁表項目,因此其空間開銷可以很小。

解題方法

逐項分辨題目談的是哪一種資源:行程是否有各自的虛擬位址空間、誰負責管理頁表、共享記憶體是否省下頁表項目,以及未使用位址範圍是否需要配置頁表。

特別注意,共享記憶體能讓多個行程共用同一批實體頁面,但各行程仍須透過自己的頁表映射這些頁面;共用實體內容不等於共用或省略頁表項目。

選項分析

(A) 正確。 一般情況下,每個使用者行程都有自己的虛擬位址空間。相同的虛擬位址在不同行程中,可以映射到不同的實體頁面。

🔒

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

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

免費註冊

第 9 題4 分

Assume that a program performs the following system calls to create file ff under directory dd and write the string “hello” to file ff:

fd = create("d/f", 0666);
write(fd, "hello", 5);

Which of the following file system operations will be involved?

(A) Get a free i-node for ff.
(B) Update the content of directory dd to include the i-node mapping of ff.
(C) Get free data block(s) for ff and link the data blocks with the i-node of ff.
(D) Write “hello” to the data block(s).

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

這一題的完整詳解

核心觀念

這題考的是檔案建立與寫入時,檔案系統如何維護 i-node、目錄項目與資料區塊。

i-node 儲存檔案的中繼資料,以及指向檔案資料區塊的資訊;目錄則透過目錄項目,記錄檔名與 i-node 的對應關係。建立檔案與寫入檔案內容是兩個相關但不同的步驟。

解題方法

先依系統呼叫的順序判斷檔案系統需要完成哪些工作:

  1. create("d/f", 0666) 在目錄 d 下建立檔案 f,需要取得可用的 i-node,並在目錄 d 中新增 f 對應到該 i-node 的目錄項目。
  2. write(fd, "hello", 5) 將 5 個位元組寫入檔案。檔案初始沒有資料區塊時,檔案系統需要配置可用資料區塊、將它們連結到 f 的 i-node,並把字串寫入資料區塊。

選項分析

🔒

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

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

免費註冊

第 10 題4 分

Assume that you use Google Chrome to browse Facebook.com via HTTPS (HyperText Transfer Protocol Secure) connections. Which of the following statements are correct? Assume there are no security vulnerabilities.

(A) The ISP (Internet Service Provider) cannot tell which website you are browsing by looking at the network traffic.
(B) The ISP cannot know the contents of the Facebook pages you are browsing by looking at the network traffic.
(C) It is impossible to know the contents of the Facebook pages you are browsing by looking at the memory content of the Google Chrome process.
(D) It is impossible to know the contents of the Facebook pages you are browsing by looking at the disk files (including executables, data files, cached web pages, etc.) of Google Chrome.

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

這一題的完整詳解

核心觀念

HTTPS 使用 TLS 保護瀏覽器與網站之間的應用層資料。網路傳輸中的頁面內容會加密,因此旁觀傳輸流量的人通常無法直接讀取頁面文字、圖片或表單內容。

加密不等於隱藏所有資訊。連線的目的 IP、流量大小與時間等中繼資料仍可被觀察;網域名稱也常可從 DNS 查詢或 TLS 握手中的 SNI 得知。另一方面,資料到達使用者的瀏覽器後,必須在瀏覽器記憶體中解密並呈現,因此端點上的資料不受「傳輸途中加密」這件事保護。

解題方法

先區分觀察位置:

  1. 網路傳輸途中:HTTPS 加密頁面內容,但部分連線中繼資料仍可能暴露。
  2. Chrome 程序記憶體:瀏覽器需要將頁面解密、排版並呈現,記憶體中會有可讀取的頁面內容。
  3. Chrome 磁碟檔案:瀏覽器可能將頁面資源、快取資料等寫入磁碟,檢查這些資料也可能取得頁面內容。

因此,看到「不可能」時,應確認該位置是否必然完全沒有頁面內容;只要有合理的資料路徑可讓內容被看見,該選項就不成立。

選項分析

🔒

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

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

免費註冊

第 11 題4 分

Which of the following statements are correct?

(A) Instructions addi and lb (load byte) both need to perform sign extension.
(B) The range of numbers represented by nn-bit 2’s complement is −(2n−1)+1∼0∼(2n−1−1)-(2^{n-1})+1\sim0\sim(2^{n-1}-1).
(C) Consider an addition of two 32-bit signed integers with a 32-bit ripple-carry adder, which consists of 32 1-bit full adders connected in series. If the carry-in and carry-out of the most-significant-bit (MSB) full adder have different logic values, then there is an overflow due to the addition.
(D) The operation of adding one very large positive integer and one very large negative integer is likely to produce an overflow.

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

這一題的完整詳解

核心觀念

本題考二補數的表示範圍,以及有號加法的溢位判斷。

nn 位元二補數的表示範圍為

−2n−1∼2n−1−1-2^{n-1}\sim 2^{n-1}-1

有號加法發生溢位的條件之一,是最高位元(符號位)的進位輸入與進位輸出不同;等價地說,兩個同號數相加,結果卻變成異號。

解題方法

逐項比對指令的符號延伸規則、二補數的範圍公式,以及有號加法的溢位條件。最後用正負號判斷不同符號的數相加是否會超出表示範圍。

選項分析

(A) 正確。 addi 將指令中的立即數符號延伸至處理器字長;lb 載入一個位元組後,會將該位元組的最高位元符號延伸至目的暫存器。因此兩者都需要符號延伸。

(B) 錯誤。 nn 位元二補數的最小值是 −2n−1-2^{n-1},不是 −(2n−1)+1-(2^{n-1})+1。

🔒

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

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

免費註冊

第 12 題4 分

Which of the following 32-bit hexadecimal data will have an identical storage sequence in byte-addressable memory, whether the machine is big-endian or little-endian?

(A) 567887651656788765_{16}
(B) 567878561656787856_{16}
(C) 566666561656666656_{16}
(D) 566556651656655665_{16}
(E) 556655661655665566_{16}

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

這一題的完整詳解

核心觀念

在位元組定址記憶體中,大端序由最高有效位元組開始存放,小端序由最低有效位元組開始存放。因此,對 32 位元資料而言,小端序的位元組排列是大端序排列的反向。

設資料的四個位元組依序為 b3,b2,b1,b0b_3,b_2,b_1,b_0。兩種端序的儲存順序相同,必須滿足:

b3=b0,b2=b1b_3=b_0,\qquad b_2=b_1

也就是四個位元組須呈現回文排列。

解題方法

每兩個十六進位數字組成一個位元組,將各選項切成四個位元組,再檢查首尾位元組是否相同、中間兩個位元組是否相同。

選項分析

  • (A) 567887651656788765_{16}
    位元組為 56, 78, 87, 6556,\ 78,\ 87,\ 65。首尾位元組 56≠6556\ne65,不符合條件。

  • (B) 567878561656787856_{16}
    位元組為 56, 78, 78, 5656,\ 78,\ 78,\ 56。首尾位元組相同,中間兩個位元組也相同。

🔒

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

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

免費註冊

第 13 題4 分

Which of the following statements are correct?

(A) The number of pipeline stages affects latency, not throughput; thus pipelining improves the performance of a processor by decreasing the latency of a job (i.e., an instruction) to be done.
(B) For a given program, its average cycles per instruction (CPI) is mainly affected by the instruction set architecture, but not affected by the programming language used.
(C) By reducing the clock frequency of a processor from 2.5 GHz2.5\ \mathrm{GHz} to 2 GHz2\ \mathrm{GHz}, and also reducing its supply voltage from 1.2 V1.2\ \mathrm{V} to 0.9 V0.9\ \mathrm{V}, the overall power consumption of this processor will be reduced by 55%55\% theoretically.
(D) According to Amdahl’s law, it is theoretically impossible to achieve a 2×2\times speedup on executing a program which is 56%56\% parallelizable, by using an 8-core multiprocessor.

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

這一題的完整詳解

核心觀念

本題考查管線化的效能指標、平均每指令週期數(CPI)、動態功率,以及阿姆達爾定律。

  • 延遲(latency):完成一項工作的時間;此處指一條指令從進入管線到完成所需的時間。

  • 吞吐量(throughput):單位時間內完成工作的數量。理想管線可讓多條指令重疊執行,提升吞吐量。

  • CPI:執行程式所需的總時脈週期數除以指令數,會受到指令組成與處理器實作等因素影響。

  • 動態功率:近似與電容、電壓平方及時脈頻率成正比:

    P∝CV2fP \propto C V^2 f

  • 阿姆達爾定律:若程式比例 pp 可平行化,使用 NN 個核心時的理想加速比為:

    S(N)=1(1−p)+pNS(N)=\frac{1}{(1-p)+\frac{p}{N}}

解題方法

逐項檢視敘述是否符合上述定義與公式。功率選項比較調整前後的功率比例;平行化選項則將可平行比例與核心數代入阿姆達爾定律,並與 22 倍加速比較。

選項分析

(A) 錯誤。
管線化的主要效益是提高吞吐量:多條指令可分處不同階段並重疊執行。管線階段數會影響指令延遲與時脈週期,也會影響理想吞吐量;在理想情況下,管線填滿後可每個週期完成一條指令。管線化不代表單條指令的延遲必然降低,因此「因降低指令延遲而改善效能」的說法錯誤。

🔒

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

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

免費註冊

第 14 題4 分

Which of the following MIPS instructions are not R-type?

(A) addi $t1, $t2, 3 — add-immediate.
(B) bne $t1, $t2, 3 — branch on not-equal.
(C) sll $t1, $t2, 3 — shift-left logical.
(D) jr $ra — jump-return.

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

這一題的完整詳解

核心觀念

MIPS 指令可依指令格式分為 R-type、I-type、J-type。判斷是否為 R-type,應看指令的編碼格式,不能只看指令名稱或功能。

R-type 指令的欄位為:

opcode(6) ∣ rs(5) ∣ rt(5) ∣ rd(5) ∣ shamt(5) ∣ funct(6)\text{opcode}(6)\ |\ rs(5)\ |\ rt(5)\ |\ rd(5)\ |\ shamt(5)\ |\ funct(6)

R-type 指令的 opcode 通常為 0,再由 funct 欄位指出實際操作。I-type 指令則包含 16 位元的立即數或位移量:

opcode(6) ∣ rs(5) ∣ rt(5) ∣ immediate(16)\text{opcode}(6)\ |\ rs(5)\ |\ rt(5)\ |\ immediate(16)

解題方法

逐一辨認各指令的編碼格式:

  • 使用立即數作為運算元的指令通常是 I-type。
  • 條件分支指令如 bne 使用 16 位元分支位移量,屬於 I-type。
  • 移位指令如 sll 使用 R-type 欄位中的 shamt 與 funct。
  • jr 雖然執行跳躍,但使用 R-type 編碼格式。

選項分析

🔒

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

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

免費註冊

第 15 題4 分

Which of the following statements are correct?

(A) A branch delay slot is defined as a sequence of instructions with neither an embedded branch (except at the end) nor a branch target (except at the beginning); a compiler identifies branch delay slots for code optimization.
(B) An issue slot is defined as a group of instructions to be issued together in the context of multiple-issue processors.
(C) 0.3125×21300.3125\times2^{130} can be represented by the IEEE 754 single-precision floating-point standard format without any loss of accuracy.
(D) Although IEEE 754 double-precision floating-point representation (denoted by double) is more precise than the single-precision counterpart (denoted by float), it is possible that float-to-double casting (conversion) causes loss of precision.

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

這一題的完整詳解

核心觀念

本題考查三個觀念:分支延遲槽與基本區塊的差別、多重發射處理器的發射封包與發射槽,以及 IEEE 754 浮點數的表示範圍與精度。

解題方法

先辨認選項中的術語是否定義正確,再檢查數值能否落在單精度的表示範圍內。單精度浮點數有 24 位有效精度(含隱藏的最高位),正規化後的指數範圍為 −126-126 至 127127;雙精度則有 53 位有效精度,且指數範圍更大。

選項分析

(A) 錯誤。
「一段指令中間沒有分支指令、且只有開頭可能是分支目標」描述的是基本區塊(basic block),不是分支延遲槽。

分支延遲槽(branch delay slot)是分支指令後方、在分支結果生效前仍會執行的指令位置;在有分支延遲槽的架構中,編譯器會嘗試安排有用指令填入該位置,以提升效率。選項把基本區塊的定義誤套在分支延遲槽上。

(B) 錯誤。
多重發射處理器可在同一個時脈週期發射多條指令。可一起發射的一組指令稱為發射封包(issue packet);

🔒

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

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

免費註冊

第 16 題4 分

The figure shows a MIPS datapath design with control and the control signal setting of the ALU control unit for R-type, lw/sw, and branch-equal instructions.

Which components in (A) and (B) are required during the operation of a Branch-on-Equal instruction? The four input control signals of the ALU control unit are AInvert, BInvert, and Operation (Fig. 1-2). Which terms in (C) and (D) should be involved in the optimal design of the control signal BInvert?

🖼️【此處有附圖,見下方】

(A) The multiplexer M1.
(B) Signed-extend unit.
(C) (ALUOp1,ALUOp0,F5,F4,F3,F2,F1,F0)=(1,X,X,X,X,X,1,X)(ALUOp1,ALUOp0,F5,F4,F3,F2,F1,F0)=(1,X,X,X,X,X,1,X).
(D) (ALUOp1,ALUOp0,F5,F4,F3,F2,F1,F0)=(X,0,X,X,0,X,X,X)(ALUOp1,ALUOp0,F5,F4,F3,F2,F1,F0)=(X,0,X,X,0,X,X,X).

🖼️ 本題附圖:
第 16 題附圖

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

這一題的完整詳解

核心觀念

這題考 MIPS 單周期資料路徑中,beq 指令會用到哪些硬體,以及 ALU 控制器如何依 ALUOp 與 R-type 的 funct 欄位產生 BInvert。

beq 會比較兩個暫存器的值;ALU 以減法判斷兩者是否相等。若要計算分支目標位址,則須將指令中的 16 位元位移量做符號延伸,再左移 2 位元並加到 PC+4。

解題方法

圖中 M1 是寫回目的暫存器編號的多工器,在 rt 與 rd 之間選擇;符號延伸單元則將指令的 16 位元立即數延伸成 32 位元,供分支目標位址計算使用。圖 1-3 的控制表顯示,beq 的 ALU 控制會使用減法,因此 BInvert=1。

依控制表,lw/sw 使用加法,ALUOp=00;beq 使用減法,ALUOp=01;R-type 指令則由 funct 欄位決定。對 R-type 而言,減法與 slt 的 F1=1,需要設定 BInvert=1。因此可將控制條件寫成:

BInvert=ALUOp0∨(ALUOp1∧F1)BInvert = ALUOp_0 \lor (ALUOp_1 \land F_1)

其中 ALUOp₀=1 涵蓋 beq;ALUOp₁=1 且 F₁=1 涵蓋需要反相第二個輸入的 R-type 指令。

選項分析

🔒

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

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

免費註冊

第 17 題4 分

Consider the parallel processor and computing design. Which of the following statements are true?

(A) As compared to conventional processors, vector processors demand less bandwidth for accessing instructions, since vector instructions replace a series of repeated instructions on a set of vectorized data.
(B) As compared to conventional processors, the execution of two adjacent vector instructions with a load-use data hazard between them can save much time for stalling because vector processors can avoid data hazard; however, conventional processors need to stall for every execution of two instructions with a load-use data hazard.
(C) The cost to establish warehouse-scale computers (WSC) is very expensive, and disks rather than processors are the main maintenance issue for WSC.
(D) The following figure shows an Omega network for a multi-core interconnection network topology and the design of a switch box. We can achieve the data transfer from P0P_0 to P6P_6 and from P1P_1 to P4P_4 concurrently.

🖼️【此處有附圖,見下方】

🖼️ 本題附圖:
第 17 題附圖

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

這一題的完整詳解

核心觀念

本題考向量處理器的指令頻寬與向量鏈結、倉庫級電腦(WSC)的維運特性,以及 Omega 多級互連網路的路徑競爭。

解題方法

圖中左側是連接 P0P_0 至 P7P_7 的 Omega 網路,由三級 2×22\times2 交換器及級間洗牌連線構成;右側畫出交換器的兩個輸入端 A、BA、B 和兩個輸出端 C、DC、D,可切換直通或交叉。判斷兩筆傳輸能否同時進行,先看它們在第一級是否要求同一交換器的同一輸出。

向量指令一次處理一組資料元素,減少反覆取指的需要。若相鄰向量指令有資料相依,向量鏈結可讓後續指令在前一指令產生部分結果後開始執行,降低等待時間;它縮短相依造成的停等,並不代表資料相依本身消失。向量鏈結說明

選項分析

  • (A) 正確。 向量指令可取代對多個資料元素逐一重複執行的指令序列,因此完成相同工作通常需要取用較少的指令,指令存取頻寬需求較低。
  • **(B) 正確。
🔒

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

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

免費註冊

第 18 題4 分

Consider the control unit and data dependency issues in MIPS pipelined CPU design. Which of the following statements are wrong?

(A) The control signals are generated in the register-read stage and then each control signal is sent to the stage that needs the control signal through pipeline registers. Since the control signal RegWrite is used by the registers in the register-read stage, RegWrite can be sent to the registers directly and does not need to be sent to pipeline registers.
(B) For double data hazard issue, such as the code sequence add $1,$1,$2; add $1,$1,$3; add $1,$1,$4, the following statement can detect one of double hazard cases: if MEM/WB.RegWrite and (MEM/WB.RegisterRd ≠0\ne 0) and not (EX/MEM.RegWrite and (EX/MEM.RegisterRd ≠0\ne 0) and (EX/MEM.RegisterRd == ID/EX.RegisterRs)) and (MEM/WB.RegisterRd == ID/EX.RegisterRs).
(C) Consider the code sequence lw $2,12($1); or $5,$4,$2; and $6,$4,$2; and $8,$2,$5, and assume the first instruction enters the pipeline CPU at the first clock cycle. The third instruction (and) enters the pipeline CPU at the third clock cycle and will stay in the second stage (register-read) for two clock cycles since the data hazard between the first and the second instructions cannot be resolved by forwarding scheme and a bubble is required for this situation.
(D) Consider the dynamic multiple-issue processor. The reservation station is used to keep the required input data from functional units or commit unit for coming instructions. As the input data for one instruction is available in a reservation station, the instruction is loaded into the associated reservation station for execution.

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

這一題的完整詳解

核心觀念

本題考查三個主題:MIPS 五級管線的控制訊號傳遞、資料轉傳的優先順序,以及動態多重發射處理器的保留站。

MIPS 五級管線通常分為取指(IF)、暫存器讀取(ID)、執行(EX)、資料存取(MEM)與回寫(WB)。控制訊號在 ID 階段產生,並隨指令經管線暫存器傳遞到實際使用它的階段。資料轉傳則要優先採用較新的結果;保留站會記錄指令及其操作數狀態,即使操作數尚未就緒,也能先接收指令並等待資料。

解題方法

逐項檢查敘述是否符合管線中「控制訊號在哪個階段生效」、「停滯時哪條指令留在哪個階段」,以及保留站「何時接收指令」等規則。B 選項則對照標準的資料轉傳條件,確認是否排除較新指令的優先結果。

選項分析

(A) 錯誤。 RegWrite 控制暫存器檔的寫入,寫入動作發生在 WB 階段,而非 ID 階段的暫存器讀取期間。因此,RegWrite 必須透過管線暫存器一路傳到 WB 階段,不能在 ID 階段直接送給暫存器檔並省略後續傳遞。

(B) 正確。 當同一個來源暫存器同時符合 EX/MEM 與 MEM/WB 的目的暫存器時,應優先採用較新的 EX/MEM 結果。題目中的條件在檢查 MEM/WB 轉傳至 ID/EX.RegisterRs 時,排除了 EX/MEM 已有較新匹配結果的情形:

🔒

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

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

免費註冊

第 19 題4 分

About memory design, which of the following statements are true?

(A) Temporal locality includes the access to induction variables.
(B) A direct-mapped cache has 32 blocks, each of which has 32 bytes. The addresses 0xB50 and 0xB54 are both mapped to block 26 in the cache.
(C) For a fixed-size cache, a design with a block that is too large tends to have a side effect: the cache read loads unnecessary data into a block, causing degradation in cache performance. This situation usually happens in matrix operations that perform on a subset of a matrix rather than on the entire matrix, such as on a subset of 256×256256\times256 elements in a matrix of 1024×10241024\times1024 elements.
(D) For a CPU running at 4 GHz4\ \mathrm{GHz} with a 2-level cache, the base CPI is 1.01.0 and the average L1-cache miss rate per instruction is 2%2\%. The average access times in the L2 cache and main memory are 3 ns3\ \mathrm{ns} and 75 ns75\ \mathrm{ns}, respectively, and the average cache miss rate is 0.4%0.4\%, which means the average rate that needs to access main memory is 0.4%0.4\%. Then the effective CPI is 2.442.44.

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

這一題的完整詳解

核心觀念

本題考查記憶體階層中的區域性、直接對映快取的位址分解,以及快取失誤造成的有效 CPI。

  • 時間區域性:近期存取過的資料,短時間內再次被存取的機率較高。
  • 空間區域性:存取某個位址後,附近位址也常被存取。
  • 直接對映快取:主記憶體區塊只能放進快取中唯一指定的區塊。若快取有 NN 個區塊、每區塊有 BB 位元組,快取區塊索引為
    ⌊位址B⌋ mod N\left\lfloor \frac{\text{位址}}{B}\right\rfloor \bmod N
  • 有效 CPI:在基礎 CPI 上,加上各層快取失誤所增加的平均停滯週期。

解題方法

逐一判斷概念敘述,並用位址除以區塊大小求快取索引;CPI 則將各種存取延遲換算成時脈週期,再依其發生率計算平均額外週期。

選項分析

(A) 正確。
迴圈中的歸納變數會在每次迭代中反覆讀取或更新。近期存取的歸納變數很快又會被存取,符合時間區域性的定義。

(B) 正確。
快取共有 3232 個區塊,每區塊 3232 位元組。位址 0xB50 所在的主記憶體區塊編號為:

⌊0xB5032⌋=⌊289632⌋=90\left\lfloor \frac{\texttt{0xB50}}{32}\right\rfloor = \left\lfloor \frac{2896}{32}\right\rfloor =90

其快取區塊索引為:

90 mod 32=2690 \bmod 32=26

0xB54 與 0xB50 相差 44 位元組,小於區塊大小 3232 位元組,因此兩者位於同一主記憶體區塊,也都對映至快取的第 2626 個區塊。

🔒

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

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

免費註冊

第 20 題4 分

For the schemes to improve the throughput of MIPS pipelined CPU, which of the following statements are true?

(A) For a speculation scheme, it is not necessary to speculate two instructions with a store preceding a load that references the same memory location. This kind of speculation allows a load to be performed before a store, since sometimes we cannot determine whether two locations referenced by a store and a load are the same due to the pointer aliasing problem.
(B) The next three sub-problems consider a static dual-issue pipelined CPU with one issue in ALU/branch instructions and another issue in store/load instructions. The use latency of the code sequence lw $3,20($1); add $5,$4,$3; sw $3,12($2) is 1andisthesameasthatofthesamecodesequencerunninginasingle−issuepipelinedCPU.Thereisnoperformancegaininthiscodesequenceusingastaticdual−issuepipelinedCPU.(C)Loopunrollingisappliedtomaketwocopiesofthecodesequence‘Loop:lw1 and is the same as that of the same code sequence running in a single-issue pipelined CPU. There is no performance gain in this code sequence using a static dual-issue pipelined CPU. (C) Loop unrolling is applied to make two copies of the code sequence `Loop: lw t0,0(s1);lws1); lw t1,4(s1);addus1); addu t0,t0,t0,t1; sw t0,0(t0,0(s1); addi s1,s1,s1,-4; bne s1,s1,zero,Loop`, and the unrolling result is shown in the following table. A=0A=0, B=12B=12, and C=4C=4.

LabelALU/branchLoad/storeCycle
Loop:addi $s1,$s1,-8lw $t0,A($s1)1
lw $t1,B($s1)2
3
addu $t0,$t0,$t1lw $t2,C($s1)4 // rename t0 as t2
sw $t0,D($s1)5
lw $t3,E($s1)6 // rename t1 as t3
addu $t0,$t2,$t37
bne $s1,$zero,Loopsw $t0,F($s1)8
(D) Follow the previous sub-problem (C), with D=8D=8, E=8E=8, and F=4F=4.

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

這一題的完整詳解

核心觀念

本題考查三個觀念:記憶體相依推測、靜態雙發射排程,以及迴圈展開後的位址調整與資料相依。

雙發射處理器每個週期最多發射兩條指令:一條 ALU/分支指令,以及一條載入/儲存指令。即使發射槽位足夠,仍須遵守資料相依與載入延遲;若某條 lw 的結果要供下一條指令使用,兩者之間至少要隔開一個週期。

解題方法

逐項檢查時,先確認指令是否能合法重排或同週期發射,再檢查迴圈展開後的記憶體位址是否仍對應原始兩次迴圈迭代。

(A) 正確

當較早的 store 與較晚的 load 是否存取同一位址尚未確定時,處理器可先讓 load 越過 store 執行,並記錄這項推測。若之後發現兩者位址相同,就必須處理錯誤推測,例如重新執行 load。

若已確定兩者存取同一位址,便不應讓 load 越過 store,因為它必須讀到 store 寫入的新值。因此,本選項所述「因指標別名問題而允許先執行 load」符合記憶體相依推測的目的。

(B) 錯誤

指令序列為:

lw  $3,20($1)
add $5,$4,$3
sw  $3,12($2)

add 使用 lw 載入的 $3,因此不能緊接著在載入後使用;但在靜態雙發射中,add 與 sw 分別占用 ALU 與載入/儲存槽,兩者沒有彼此的資料相依,可以同週期發射。

一種合法排程如下:

週期ALU/分支槽載入/儲存槽
1—lw $3,20($1)
2——
3add $5,$4,$3`sw $3,12(
🔒

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

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

免費註冊
📄 以下 4 題共用同一段題幹

Consider the following set of processes performed on a single-core processor. These processes arrive at the following arrival times, with the length of the CPU burst given in the table:

ProcessArrival TimeCPU Burst Time
P1P_106
P2P_228
P3P_335
P4P_453
P5P_571

Please calculate the waiting time WW under the preemptive shortest-remaining-time first scheduling method. Assume W=W3×43+W2×42+W1×41+W0W=W_3\times4^3+W_2\times4^2+W_1\times4^1+W_0 (0≤W0,W1,W2,W3<4)(0\leq W_0,W_1,W_2,W_3<4). Choose the correct values of W3W_3, W2W_2, W1W_1, and W0W_0.

第 21 題

W3=?W_3=?

(A) 33
(B) 22
(C) 11
(D) 00

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

這一題的完整詳解

核心觀念

搶先式最短剩餘時間優先(SRTF)每次有新行程抵達時,都比較所有已抵達且尚未完成的行程之「剩餘 CPU 執行時間」,選擇剩餘時間最短者執行。若新抵達行程的剩餘時間更短,便會搶先目前正在執行的行程。

單一行程的等待時間可由完成時間計算:

等待時間=完成時間−抵達時間−CPU burst 時間等待時間=完成時間-抵達時間-CPU\ burst\ 時間

題目中的 WW 是所有行程等待時間的總和,再以四進位位權形式表示。

解題方法

依抵達事件逐段排出執行順序:

  • t=0t=0 至 t=2t=2:只有 P1P_1,執行後剩餘 44。
  • t=2t=2 時 P2P_2 抵達:P1P_1 剩餘 44,短於 P2P_2 的 88,P1P_1 繼續。
  • t=3t=3 時 P3P_3 抵達:P1P_1 剩餘 33,短於 P3P_3 的 55,P1P_1 繼續。
  • t=5t=5 時 P4P_4 抵達:P1P_1 剩餘 11,短於 P4P_4 的 33,P1P_1 繼續至 t=6t=6 完成。
  • t=6t=6:P4P_4 的 33 短於 P3P_3 的 55、P2P_2 的 88,因此執行 P4P_4。
  • t=7t=7 時 P5P_5 抵達,執行時間為 11,短於 P4P_4 剩餘的 22,因此搶先執行並於 t=8t=8 完成。
  • t=8t=8:P4P_4 剩餘 22,短於 P3P_3 的 55、P2P_2 的 88,執行至 t=10t=10 完成。
  • 接著執行 P3P_3 至 t=15t=15,最後執行 P2P_2 至 t=23t=23。

甘特圖如下:

🔒

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

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

免費註冊

第 22 題

W2=?W_2=?

(A) 33
(B) 22
(C) 11
(D) 00

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

這一題的完整詳解

核心觀念

搶先式最短剩餘時間優先(preemptive SRTF)會在每個新行程抵達時,比較目前執行行程的剩餘 CPU 時間與新行程的 CPU burst time,選擇剩餘時間最短者執行。執行中的行程若不再是最短者,就會被搶先。

每個行程的等待時間為:

Wi=完成時間−抵達時間−CPU burst timeW_i=\text{完成時間}-\text{抵達時間}-\text{CPU burst time}

題目中的 WW 是所有行程等待時間的總和,再以四進位表示。

解題方法

依照各行程抵達時間更新排程,得到下列執行順序:

時間區間執行行程說明
0–60\text{–}6P1P_1P1P_1 的剩餘時間始終短於其他可執行行程
6–76\text{–}7P4P_4P1P_1 完成後,P4P_4 剩餘時間最短
7–87\text{–}8P5P_5P5P_5 抵達,burst time 為 11,搶先執行
8–108\text{–}10P4P_4P5P_5 完成後,執行 P4P_4 剩餘的 22 單位時間
10–1510\text{–}15P3P_3P4P_4 完成後,P3P_3 剩餘時間最短
🔒

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

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

免費註冊

第 23 題

W1=?W_1=?

(A) 33
(B) 22
(C) 11
(D) 00

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

這一題的完整詳解

核心觀念

最短剩餘時間優先(SRTF)是可搶先式排程。每當新行程抵達或目前行程完成時,處理器都選擇「已抵達且尚未完成」的行程中,剩餘 CPU 時間最短者;若新抵達行程的剩餘時間更短,就會搶占目前行程。

單一行程的等待時間可由完成時間計算:

等待時間=完成時間−抵達時間−CPU 執行時間\text{等待時間}=\text{完成時間}-\text{抵達時間}-\text{CPU 執行時間}

題目中的 WW 為所有行程等待時間的總和,再以四進位表示。

解題方法

依照各時刻的抵達事件與剩餘時間,排出執行順序:

時間區間執行行程說明
00–66P1P_1P1P_1 的剩餘時間始終短於其他已抵達行程
66–77P4P_4此時 P4P_4 剩餘時間為 33,最短
77–88P5P_5P5P_5 抵達,執行時間為 11,搶占 P4P_4
88–1010P4P_4P4P_4 剩餘時間為 22,短於 P3P_3 與 P2P_2
1010–1515P3P_3P3P_3 的剩餘時間為 55,短於 P2P_2
1515–2323P2P_2最後執行剩餘的 88 單位時間

依此得到完成時間:P1=6P_1=6、P2=23P_2=23、P3=15P_3=15、P4=10P_4=10、P5=8P_5=8。計算各行程等待時間:

🔒

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

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

免費註冊

第 24 題

W0=?W_0=?

(A) 33
(B) 22
(C) 11
(D) 00

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

這一題的完整詳解

核心觀念

最短剩餘時間優先(SRTF)是可搶先的排程法:每當有新行程抵達,或目前行程完成時,處理器都選擇「已抵達且尚未完成」的行程中,剩餘 CPU 時間最短者。

各行程的等待時間可由周轉時間計算:

等待時間=完成時間−抵達時間−CPU 執行時間\text{等待時間}=\text{完成時間}-\text{抵達時間}-\text{CPU 執行時間}

題目中的 WW 是所有行程等待時間的總和,再以四進位表示。

解題方法

依照 SRTF 規則排程:

  • 00 到 66:執行 P1P_1。新行程抵達時,P1P_1 的剩餘時間仍短於其他行程,因此不中斷。
  • 66 到 77:執行 P4P_4。此時 P4P_4 的執行時間最短。
  • 77 到 88:P5P_5 抵達,剩餘時間為 11,因此搶先執行並完成。
  • 88 到 1010:接著執行剩餘時間為 22 的 P4P_4。
  • 1010 到 1515:執行 P3P_3。
  • 1515 到 2323:執行 P2P_2。

甘特圖如下:

0  ∣  P1  ∣  6  ∣  P4  ∣  7  ∣  P5  ∣  8  ∣  P4  ∣  10  ∣  P3  ∣  15  ∣  P2  ∣  230\;|\;P_1\;|\;6\;|\;P_4\;|\;7\;|\;P_5\;|\;8\;|\;P_4\;|\;10\;|\;P_3\;|\;15\;|\;P_2\;|\;23

各行程等待時間為:

🔒

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

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

免費註冊
📄 以下 2 題共用同一段題幹

Consider the following memory map of a cat process running on a Linux system at the NCTU CS computing center:

00400000-0040b000 r-xp 00000000 fd:00 33634378 /usr/bin/cat
0060b000-0060c000 r--p 0000b000 fd:00 33634378 /usr/bin/cat
0060c000-0060d000 rw-p 0000c000 fd:00 33634378 /usr/bin/cat
00d87000-00da8000 rw-p 00000000 00:00 0 [heap]
7f11d3b8c000-7f11da0b6000 r--p 00000000 fd:00 100737152 /usr/lib/locale/locale-archive
7f11da0b6000-7f11da279000 r-xp 00000000 fd:00 67216364 /usr/lib64/libc-2.17.so
7f11da279000-7f11da47d000 ---p 001c3000 fd:00 67216364 /usr/lib64/libc-2.17.so
7f11da47d000-7f11da47e000 r--p 001c3000 fd:00 67216364 /usr/lib64/libc-2.17.so
7f11da47e000-7f11da47f000 rw-p 001c4000 fd:00 67216364 /usr/lib64/libc-2.17.so
7f11da47f000-7f11da480000 rw-p 00000000 00:00 0
7f11da480000-7f11da486000 r-xp 00000000 fd:00 67778326 /usr/lib64/ld-2.17.so
7f11da690000-7f11da691000 r--p 00000000 fd:00 0
7f11da691000-7f11da6a5000 rw-p 00000000 00:00 0
7f11da6a5000-7f11da6a6000 r--p 00005000 fd:00 67778326 /usr/lib64/ld-2.17.so
7f11da6a6000-7f11da6a7000 rw-p 00006000 fd:00 67778326 /usr/lib64/ld-2.17.so
7ffed373a000-7ffed375c000 rw-p 00000000 00:00 0 [stack]
7ffed37b1000-7ffed37b3000 r-xp 00000000 00:00 0 [vdso]
ffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]

第 25 題

Which memory region contains the executable code of the cat program?

(A) 00400000-0040b000
(B) 0060b000-0060c000
(C) 0060c000-0060d000
(D) None of the above.

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

這一題的完整詳解

核心觀念

Linux 程序的記憶體映射表會列出各區域的虛擬位址範圍、存取權限與對應檔案。權限欄中的 r 代表可讀、w 代表可寫、x 代表可執行;p 代表私有映射。

可執行檔的程式碼通常位於具有執行權限的映射區域,因此判斷時應先找出權限欄含有 x,再確認該列對應的是 /usr/bin/cat。

解題方法

檢查題目中 /usr/bin/cat 的三段映射:

  • 00400000-0040b000 r-xp ... /usr/bin/cat:可讀、可執行,對應 cat 的程式碼區域。
  • 0060b000-0060c000 r--p ... /usr/bin/cat:唯讀,不可執行。
  • 0060c000-0060d000 rw-p ... /usr/bin/cat:可讀、可寫,不可執行。
🔒

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

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

免費註冊

第 26 題

Which is the physical address range containing the executable code of the C library?

(A) 7f11da0b6000-7f11da279000
(B) 7f11da479000-7f11da47d000
(C) 7f11da47d000-7f11da47f000
(D) None of the above.

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

這一題的完整詳解

核心觀念

題目考的是 Linux 行程記憶體映射表的欄位判讀,以及虛擬位址與實體位址的差別。

/proc/<pid>/maps 顯示的是行程的虛擬位址區間。權限欄位中的 r、w、x 分別代表可讀、可寫、可執行;p 代表私有映射。實體頁框位址需透過頁表等資訊才能得知,不能直接由這份映射表讀出。

解題方法

先依路徑 /usr/lib64/libc-2.17.so 找出 C 函式庫的映射,再看權限欄位。其可執行的程式碼段標示為 r-xp,位址範圍是 7f11da0b6000-7f11da279000。

但這個範圍是虛擬位址範圍,不是實體位址範圍。題目要求的是實體位址,而提供的記憶體映射表不包含實體頁框資訊,因此無法從題目資料判定該範圍的實體位址。

選項分析

🔒

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

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

免費註冊

第 27 題

When memory space becomes tight, we may need to swap out memory pages to the disk. Which of the following statements about swapping out memory pages is correct?

(A) We can skip swapping out memory pages that are backed by a memory-mapped file.
(B) We can skip swapping out memory pages that are dirty.
(C) We can skip swapping out anonymous pages (pages that are not backed by a memory-mapped file).
(D) The number of anonymous pages that can be swapped out is bounded by the size of the swap file (or the swap partition) on the disk.

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

這一題的完整詳解

核心觀念

記憶體回收時,作業系統要確保被移出的頁面之後仍能還原。關鍵在於頁面的備份位置:

  • 檔案映射頁面有原始檔案作為備份。乾淨頁面可直接丟棄,需要時再從檔案讀回;髒頁面須先寫回原始檔案。
  • 匿名頁面沒有對應的檔案可供重新讀取。若要移出記憶體,必須將內容存到交換空間,之後才能還原。

解題方法

逐一判斷各選項描述的頁面是否需要使用交換空間。要分清楚「寫回原始檔案」與「寫入交換空間」:檔案映射頁面的髒資料可能需要寫回檔案,但這不等於寫入交換空間;匿名頁面則需要交換空間保存。

選項分析

🔒

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

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

免費註冊
📄 以下 3 題共用同一段題幹

Consider a 32-bit ALU, consisting of 32 1-bit ALUs connected in series, as shown in the following figure, where:

  • A NOT gate (inverter) has a propagation delay of 1 unit.
  • An AND gate has a propagation delay of 1 unit.
  • An OR gate has a propagation delay of 1 unit.
  • A 2-to-1 mux has a propagation delay of 2 units.
  • A 4-to-1 mux has a propagation delay of 4 units.
  • A full adder (square) has a propagation delay of 3 units.
  • Overflow detection (rectangle) has a propagation delay of 3 units.

🖼️【此處有附圖,請對照原卷】

第 28 題

What is the worst-case (i.e., maximum) cumulative propagation delay for a 32-bit bitwise NOR operation/instruction?

(A) 77 units.
(B) 88 units.
(C) 3232 units.
(D) 9696 units.

🖼️ 本題附圖:
第 28 題附圖

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

這一題的完整詳解

核心觀念

傳播延遲是訊號沿著最慢的邏輯路徑,依序通過各元件所需延遲的總和。逐位元邏輯運算各位獨立計算,不需要經過 32 位元的進位鏈,因此延遲不會乘上 32。

解題方法

圖中每個 1-bit ALU 的 AA、BB 輸入都可經反相器後,由 2-to-1 多工器選擇正相或反相訊號;AND、OR、全加器的輸出再由 4-to-1 多工器選出。32 個 ALU 雖串接進位,但 NOR 運算不使用進位。

每一位的 NOR 可依德摩根定律寫成:

A∨B‾=A‾∧B‾\overline{A \lor B} = \overline{A} \land \overline{B}

沿著任一輸入到結果的最慢路徑,訊號經過反相器、2-to-1 多工器、AND 閘及 4-to-1 多工器,總延遲為:

🔒

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

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

免費註冊

第 29 題

What is the worst-case (i.e., maximum) cumulative propagation delay for a 32-bit ADD operation/instruction?

(A) 99 units.
(B) 1010 units.
(C) 100100 units.
(D) 102102 units.

🖼️ 本題附圖:
第 29 題附圖

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

這一題的完整詳解

核心觀念

這題考 32 位元漣波進位加法器的最壞傳播延遲。串接的全加器會逐位傳遞進位,因此延遲要沿最長的訊號路徑累加;同一位元的兩個輸入多工器則是平行運作,延遲取其中一條路徑的時間,不互相相加。

解題方法

圖中是 32 個 1-bit ALU 串接;每個位元的輸入經過 2-to-1 mux,延遲為 2 units,全加器延遲為 3 units,輸出再經過 4-to-1 mux,延遲為 4 units。進位由低位一路傳至最高位。圖中的 overflow detection 是另一條輸出路徑,不在 Result 的路徑上。

因此,最壞路徑由輸入多工器開始,經過 32 個全加器級,再通過結果多工器:

🔒

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

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

免費註冊

第 30 題

What is the worst-case (i.e., maximum) cumulative propagation delay for an SLT (set on less-than) operation/instruction?

(A) 9999 units.
(B) 100100 units.
(C) 102102 units.
(D) 103103 units.

🖼️ 本題附圖:
第 30 題附圖

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

這一題的完整詳解

核心觀念

本題考的是 漣波進位 ALU 的最長訊號傳遞路徑。串接路徑上的延遲要相加;平行支路則取最晚到達的訊號,不能把所有元件的延遲全部相加。

SLT 利用 A−BA-B 產生比較結果,再將最高位元的 Set 訊號送回最低位元的 Less 輸入,使輸出最低位元表示比較結果,其餘位元輸出 00。

解題方法

圖中共有 3232 個串接的全加器,前一級的 CarryOut 接到下一級的 CarryIn。最高位元的 Set 直接取自全加器輸出,再回接至最低位元的 Less,最後經過最低位元的四選一多工器輸出;此路徑未經過溢位偵測方塊。

SLT 執行減法時,使用二補數運算:

A−B=A+B‾+1A-B=A+\overline{B}+1

因此,最長路徑依序為:

  1. 將 BB 反相並選入運算路徑
    BB 先通過反相器,再通過二選一多工器,延遲為

    t輸入=1+2=3t_{\text{輸入}}=1+2=3
  2. 進位逐級傳遞,直到最高位元產生 Set
    最低位元先產生進位,接著經過其餘 3131 級全加器,最高位元全加器最後產生 Set。共須計入 3232 級全加器:

    tSet=3+32×3=99t_{\text{Set}}=3+32\times3=99
  3. Set 回送至最低位元並輸出
    Set 接到最低位元的 Less 後,還須通過四選一多工器,增加 44 單位延遲:

🔒

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

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

免費註冊
📄 以下 3 題共用同一段題幹

Consider the (7,4)(7,4) Hamming code. Each code word contains seven bits, c1,c2,d1,c3,d2,d3,d4c_1,c_2,d_1,c_3,d_2,d_3,d_4, satisfying the following three equations:

c1⊕d1⊕d2⊕d4=0,c2⊕d1⊕d3⊕d4=0,c3⊕d2⊕d3⊕d4=0.c_1\oplus d_1\oplus d_2\oplus d_4=0,\qquad c_2\oplus d_1\oplus d_3\oplus d_4=0,\qquad c_3\oplus d_2\oplus d_3\oplus d_4=0.

As we add an additional parity bit, c4c_4, at the end, the code can detect two errors. One additional equation holds for this need:

c1⊕c2⊕d1⊕c3⊕d2⊕d3⊕d4⊕c4=0.c_1\oplus c_2\oplus d_1\oplus c_3\oplus d_2\oplus d_3\oplus d_4\oplus c_4=0.

第 31 題

As receiving 7-bit data (1 1 0 1 1 0 0)(1\ 1\ 0\ 1\ 1\ 0\ 0):

(A) The received data is correct.
(B) The received data has one bit error in c1c_1.
(C) The received data has one bit error in c2c_2.
(D) The received data has one bit error in d2d_2.

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

這一題的完整詳解

核心觀念

(7,4)(7,4) Hamming code 以三條同位檢查方程式計算症候(syndrome)。若收到的資料滿足所有方程式,症候為 000000;若只有一個位元錯誤,症候會等於該位元在三條檢查方程式中的參與位置。

令三條方程式的檢查結果依序為 s1,s2,s3s_1,s_2,s_3。每個 sis_i 是該方程式左側所有位元的 XOR 值;因為正確碼字的檢查結果皆為 00,所以非零症候表示收到的資料有錯。

解題方法

收到的 7 位元依序對應 (c1,c2,d1,c3,d2,d3,d4)=(1,1,0,1,1,0,0)(c_1,c_2,d_1,c_3,d_2,d_3,d_4)=(1,1,0,1,1,0,0)。代入三條檢查方程式:

s1=c1⊕d1⊕d2⊕d4=1⊕0⊕1⊕0=0,s2=c2⊕d1⊕d3⊕d4=1⊕0⊕0⊕0=1,s3=c3⊕d2⊕d3⊕d4=1⊕1⊕0⊕0=0.\begin{aligned} s_1 &= c_1\oplus d_1\oplus d_2\oplus d_4 =1\oplus0\oplus1\oplus0=0,\\ s_2 &= c_2\oplus d_1\oplus d_3\oplus d_4 =1\oplus0\oplus0\oplus0=1,\\ s_3 &= c_3\oplus d_2\oplus d_3\oplus d_4 =1\oplus1\oplus0\oplus0=0. \end{aligned}
🔒

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

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

免費註冊

第 32 題

As receiving 8-bit data (1 0 1 1 0 1 0 1)(1\ 0\ 1\ 1\ 0\ 1\ 0\ 1):

(A) The received data is correct.
(B) The received data has an error in bit d1d_1.
(C) The received data has an error in bit c2c_2.
(D) The received data has an error in bit c4c_4.

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

這一題的完整詳解

核心觀念

此題考延伸漢明碼的症候(syndrome)判讀。前三個檢查式用來定位 c1,c2,d1,c3,d2,d3,d4c_1,c_2,d_1,c_3,d_2,d_3,d_4 中的單一位元錯誤;新增的整體同位檢查式則用來判斷錯誤位元是否在 c4c_4。

依題目位元順序 (c1,c2,d1,c3,d2,d3,d4,c4)(c_1,c_2,d_1,c_3,d_2,d_3,d_4,c_4),計算前三個檢查式的結果為 (s1,s2,s3)(s_1,s_2,s_3)。若三者皆為 00,代表原本七位漢明碼的檢查通過;再看八位元的整體 XOR 是否為 00。

解題方法

收到的資料為 (1,0,1,1,0,1,0,1)(1,0,1,1,0,1,0,1),因此:

(c1,c2,d1,c3,d2,d3,d4,c4)=(1,0,1,1,0,1,0,1)(c_1,c_2,d_1,c_3,d_2,d_3,d_4,c_4) =(1,0,1,1,0,1,0,1)

代入前三個檢查式:

s1=c1⊕d1⊕d2⊕d4=1⊕1⊕0⊕0=0s_1=c_1\oplus d_1\oplus d_2\oplus d_4 =1\oplus1\oplus0\oplus0=0 s2=c2⊕d1⊕d3⊕d4=0⊕1⊕1⊕0=0s_2=c_2\oplus d_1\oplus d_3\oplus d_4 =0\oplus1\oplus1\oplus0=0 s3=c3⊕d2⊕d3⊕d4=1⊕0⊕1⊕0=0s_3=c_3\oplus d_2\oplus d_3\oplus d_4 =1\oplus0\oplus1\oplus0=0

前三個檢查式都通過,表示 c1,c2,d1,c3,d2,d3,d4c_1,c_2,d_1,c_3,d_2,d_3,d_4 沒有被檢查出錯誤。接著計算八位元的整體 XOR:

🔒

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

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

免費註冊

第 33 題

As receiving 8-bit data (1 0 0 0 1 0 1 1)(1\ 0\ 0\ 0\ 1\ 0\ 1\ 1):

(A) The received data has double errors.
(B) The received data is correct.
(C) The received data has an error in d3d_3.
(D) The received data has an error in c4c_4.

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

這一題的完整詳解

核心觀念

(7,4)(7,4) Hamming code 的前三條校驗式可計算症候值。若收到的位元違反某條校驗式,該式的結果為 11;符合則為 00。三個症候位元可用來定位單一錯誤。

加入整體同位元 c4c_4 後,第四條校驗式檢查全部 8 個位元的偶同位。結合前三個症候位元與整體同位檢查,可判斷單錯誤或偵測雙錯誤:

  • 症候非零、整體同位檢查結果為 11:單一錯誤。
  • 症候非零、整體同位檢查結果為 00:雙重錯誤。
  • 症候為零、整體同位檢查結果為 11:錯誤在 c4c_4。
  • 症候為零、整體同位檢查結果為 00:資料正確。

解題方法

收到的 8 位元為 (1,0,0,0,1,0,1,1)(1,0,0,0,1,0,1,1),依題目順序對應:

(c1,c2,d1,c3,d2,d3,d4,c4)=(1,0,0,0,1,0,1,1)(c_1,c_2,d_1,c_3,d_2,d_3,d_4,c_4) =(1,0,0,0,1,0,1,1)

將數值代入前三條校驗式:

s1=c1⊕d1⊕d2⊕d4=1⊕0⊕1⊕1=1s_1=c_1\oplus d_1\oplus d_2\oplus d_4 =1\oplus0\oplus1\oplus1=1 s2=c2⊕d1⊕d3⊕d4=0⊕0⊕0⊕1=1s_2=c_2\oplus d_1\oplus d_3\oplus d_4 =0\oplus0\oplus0\oplus1=1 s3=c3⊕d2⊕d3⊕d4=0⊕1⊕0⊕1=0s_3=c_3\oplus d_2\oplus d_3\oplus d_4 =0\oplus1\oplus0\oplus1=0

因此症候為 (s1,s2,s3)=(1,1,0)(s_1,s_2,s_3)=(1,1,0),不是零,表示前三個校驗式中至少有一條不符合。

再計算 8 個位元的整體同位:

🔒

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

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

免費註冊

其他考古題