快轉到主要內容

《作業系統》期末考複習 — 是非題篇

·486 字
目錄
大三上學期期末考複習 - 本文章屬於一個系列🍒。
◆ : 你在這裡!

⭐ 題目出自考古題

是非題
#

🍮1. A thread is composed of ( 組成 ) a thread ID, program counter, register set, and heap.
#

  • 🍫答案 : False ❌
  • 解釋 : 應該把 Heap 換成 Stack。

🍮2. Virtually all contemporary operating systems support ( 支持 ) kernel threads.
#

  • 🍫答案 : True ✅
  • 解釋 : 幾乎所又 OS 都支持 kernel threads。

🍮3. A deadlock-free solution eliminates ( 消除 ) the possibility of starvation.
#

  • 🍫答案 : False ❌
  • 解釋 : 沒有 Dead-Lock 依然可能發生 starvation。

🍮4. Monitors are a theoretical concept ( 理論概念 ) and are not practiced in ( 不實行 ) modern programming languages.
#

  • 🍫答案 : False ❌
  • 解釋 : Java 的 synchronizedwait()notify(),以及 C# 的 lock,本質上都是 monitor 的實作。

🍮5. Deadlock prevention ( 預防 ) and deadlock avoidance ( 避免 ) are essentially the same approaches for handling deadlock.
#

  • 🍫答案 : False ❌
  • 解釋 : 兩者是截然不同的機制。

🍮6. If a resource-allocation graph has a cycle ( 圈圈 ), the system must be in a deadlocked state ( 死結 ).
#

  • 🍫答案 : False ❌
  • 解釋 : 總之就是錯的。

🍮7. A 32-bit logical address ( 邏輯位址 ) with 8 KB page size will have 1,000,000 entries ( 條目 ) in a conventional page table.
#

  • 🍫答案 : False ❌
  • 解釋 :
    • \(1 \text{ KB} = 1024 \text{ bytes} = 2^{10} \text{ bytes}\)
    • \(8 \text{ KB} = 8 \times 2^{10} = 2^3 \times 2^{10} = \mathbf{2^{13}}\) bytes
    • 分頁表的條目數 (Entries) 等於「總空間」除以「每一頁的大小」:
    • \[\text{Number of Entries} = \frac{\text{Total Address Space}}{\text{Page Size}}\]
    • \[\frac{2^{32}}{2^{13}} = 2^{32 - 13} = \mathbf{2^{19}}\]
      • 我們知道 \(2^{10} \approx 1 \text{ K}\) (一千),\(2^{20} \approx 1 \text{ M}\) (一百萬)。
      • \(2^{19}\) 剛好是 \(2^{20}\) 的一半。
      • 精確數值:\(2^{19} = 524,288\)。
      • 題目說有 1,000,000 (一百萬) 個 entries,但實際上只有 524,288 (約五十萬) 個。 所以答案是 False。

🍮8. Inverted page tables ( 反轉分頁表 ) require each process to have its own ( 自己的 ) page table.
#

  • 🍫答案 : False ❌
  • 解釋 : 反轉分頁表的設計目的正是為了節省記憶體,所以整個系統只有「唯一一張」分頁表,所有行程共用這一張。

🍮9. On a system with demand-paging, a process will experience ( 發生 ) a high page fault rate when the process begins execution ( 執行 ).
#

  • 🍫答案 : True ✅
  • 解釋 : 當程式剛被啟動時,記憶體裡面是 全空 的(沒有任何該程式的 Page)。
    • CPU 執行第一行指令 \(\rightarrow\) 不在 RAM \(\rightarrow\) Page Fault (載入第 1 頁)。
    • CPU 要讀取變數 \(\rightarrow\) 不在 RAM \(\rightarrow\) Page Fault (載入第 2 頁)。
    • CPU 呼叫函式 \(\rightarrow\) 不在 RAM \(\rightarrow\) Page Fault (載入第 3 頁)。
    • 由於初期需要的資料通通都不在 RAM 裡,所以會連續不斷地觸發中斷去硬碟搬資料。

🍮10. If the page-fault rate is too high, the process may have too many ( 太多 ) frames.
#

  • 🍫答案 : False ❌
  • 解釋 : 剛好相反,應該是被分到的 Frames 太少 ( 也就是 Thrashing)。

⭐ Page -> 虛擬的 ; Frame -> 實際存在 RAM 的。


🍮11. Hashed page tables are particularly useful ( 有用 ) for processes with sparse address spaces ( 稀疏位址空間 ).
#

  • 🍫答案 : True ✅
  • 解釋 :
    1. 傳統分頁表
      • 傳統分頁表(如陣列或多階層分頁表)的結構是基於「索引」的。
      • 如果你用了第 0 頁和第 1,000,000 頁:
        • 傳統做法: 可能需要建立中間所有的表格結構(即使中間是空的),或者建立很多層的 Page Table 來跳過中間的空洞。這會造成記憶體浪費,因為你要維護那些「空的」對應關係。
    2. 雜湊分頁表
      • 原理 : 它不再是「陣列 (Array)」,而是「雜湊表 (Hash Map)」。
      • 儲存方式 : 它只儲存 「有被用到的頁面」。
      • 如果中間有 100 萬頁是空的,雜湊表就完全不會紀錄這 100 萬頁,完全不佔用空間。

⭐ sparse address space : 你的程式「號稱」可以用 0 ~ 1,000,000 的位址,但實際上你只用了第 1 頁和第 1,000,000 頁。


大三上學期期末考複習 - 本文章屬於一個系列🍒。
◆ : 你在這裡!

相關文章