More Related Content
Similar to 程式設計師的自我修養 Chapter 1
Similar to 程式設計師的自我修養 Chapter 1 (20)
程式設計師的自我修養 Chapter 1
- 1. 程式設計師的自我修養
連結. 載入. 程式庫
Shu-Yu Fu (shuyufu@gmail.com)
- 2. 第一篇 簡介
1. Chapter 1 溫故而知新
a. 從Hello World說起
b. 萬變不離其宗
c. 站得高,望得遠
d. 作業系統的功能
e. 記憶體不夠麼辦
f. 團結力量大
g. 本章小結
- 9. 作業系統的功能
● 管理CPU、記憶體、I/O設備
● CPU
○ 多重程式,Multiprogramming
○ 分時系統,Time-Sharing System
○ 多工系統,Multi-tasking
■ 行程,Process
■ 先佔式,Preemptive
● 硬體驅動程式(Device Driver)
○ 讀檔
- 10. 記憶體不夠怎麼辦
● 位址空間不隔離
● 記憶體使用效率低
● 程式執行的位址不確定
● 虛擬位址,Virtual Address
○ 分段
○ 分頁
- 12. 分頁
● 虛擬頁,Virtual Page
● 實體頁,Physical Page
● 磁碟頁,Disk Page
● 分頁錯誤(Page Fault)
● MMU,Memory Management Unit
- 17. 緒程排程(cont.)
● 優先順序排程(Priority Schedule)
○ 緒程優先順序(Thread Priority)
● 輪轉法(Round Robin)
● 餓死(Starvation)
○ 使用者指定優先順序
○ 根據進入等待狀態的頻繁程度提升或降低優先順序
■ IO密集型緒程(IO Bound Thread)
■ CPU密集型緒程(CPU Bound Thread)
○ 長時間得不到執行而被提升優先順序
● 先佔(Preemption)
- 19. 緒程安全
● void inc_x () { x++; }
● 原子(Atomic)操作,glib
● Semaphore《Glib Semaphores》
○ 可以被任意緒程獲取並釋放
● Mutex《類似binary semaphore》glib
○ 哪個緒程獲取了互斥器,哪個緒程就要負釋放這個鎖
定
● Criticsl Section
● Read-Write Lock
○ Sema、Mutex、CS遇到偶爾寫入的情況,效能不彰
● Condition Variable