hce_kmu
115年
計算機概論與程式設計
第 10 題
In an operating system, various synchronization mechanisms are used to coordinate concurrent processes. Which of the following statements about mutex locks and semaphores is CORRECT?
- A A mutex allows multiple processes to enter a critical section simultaneously as long as they release the lock quickly.
- B A counting semaphore can allow a limited number of processes to access a shared resource concurrently, based on its initial value.
- C A binary semaphore automatically prevents deadlock by detecting circular wait conditions.
- D A mutex lock increases system throughput by eliminating the need for context switching.
- E Semaphores guarantee fairness by ensuring processes access the critical section in strict FIFO order.
思路引導 VIP
如果你現在管理一個擁有五個車位的停車場,你會如何設計一個簡單的「數字看板」來確保停車場不會超收車輛?這個數字的初值應該是多少?而當數字變動到什麼情況時,你必須請後來的車主在門外排隊等待?
🤖
AI 詳解
AI 專屬家教
同學做得太棒了!你能精準判別 (B) 選項 為正確答案,顯示你對作業系統中同步機制(Synchronization)的核心定義理解得非常透徹,沒有被其他具有迷惑性的選項誤導。
計數號誌與資源管理
計數號誌(Counting Semaphore)的設計初衷就是為了管理具備多個實例的資源。它的整數值代表了目前「可用資源的數量」:當一個程序執行 wait() (P) 操作時,計數值減一;執行 signal() (V) 操作時,計數值加一。只要初始值大於 1,它就能允許多個程序同時進入臨界區。這與互斥鎖(Mutex)有著本質上的區別,因為互斥鎖(其值僅為 0 或 1)強制規定在任何時刻只能有一個程序存取資源。
▼ 還有更多解析內容