Uploaded by 李芳馨

410821208 李芳馨-OS第一次作業

advertisement
410821208_李芳馨___OS_HW1
1.8: What is the purpose of interrupts?
保護系統資源(protect system resource),且相對於原本的方法,有較高的工
作效率。因為原本的 polling 方法,是向裝置透過無盡的迴圈(busying
waiting)進行反覆詢問裝置是否完成動作並返回結果,雖然簡單當相當沒效
率,所以改用 interrupt 的方式,在裝置完成動作後打斷原本工作,待中斷結
束後繼續原本工作。
How does an interrupt differ from a trap?
(1) Interrupt 由硬體產生(hardware interrupt),被用來當作 I/O complete 的
訊號。
(2)Trap 又稱為 exception,由軟體產生(software interrupt),被用來 call os.
routine 或是 catch arithmetic error。因為錯誤(ex.除以 0 或不正確的記憶體
存取) 或由使用者程式提出需要作業系統服務的特定要求所產生。
Can traps be generated intentionally by a user program? If so, for what
purpose?
可以。目的是不讓程式產生無限迴圈或存取到不合法的記憶體位置,當以上其
一狀況發生時,就會觸發 trap 而中斷。(如 system call)
1.10 Some computer systems do not provide a privileged mode of
operation in hardware. Is it possible to construct a secure operating
system for these computer systems? Give arguments both that it is and
that it is not possible.
Possible:
要在某些特殊的狀況下才能達成。像是只有一個人在使用該系統,就能夠確定
在其他程序執行時,不會影響到核心。
not possible:
因為透過 mode bit 指令(User mode==0,Kernel mode==1)控制能否使用
privileged mode,若不能透過 mode bit 去判斷是否能夠使用 privileged ,
將造成 user 和 kernel 的指令混雜在一起。
Why dual mode operation can protect system?
→因為會對硬體(hardware)重要的資源(resources)進行保護,把可能造成問題
的一些機器指令設為特權指令(privileged instruction)。防止使用者程式直接使
用,即可避免使用者使用而造成系統或危害到其他使用者。
藉由在 user mode 和 monitor mode 之間切換,讓使用者無法使用
privileged instruction,達到防止的效果。
Download