技術根兒扎得深,不怕“首都”狂風吹!

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" 始終相信那句話 “種下一棵樹最好的時候是十年前,其次是現在”。對於如何構建知識體系我有自己的門道。其實就是基礎知識,它就像一顆樹的根,要扎的經可能的深,汲取大地中更多養分已供養大樹的枝繁葉茂。操作系統就是其中一條根!","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"《重拾操作系統》","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"第一篇:成長之路","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"操作系統是一種複雜的系統軟件,是不同代碼程序,數據結構,數據初始化文件的集合,可執行。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"1.職業目標","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1.與硬件部分相互作用,爲包含在硬件平臺上的所用底層可編程部件提供服務。","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"顯示器,必須爲驅動顯示器工作的一些寄存器賦值。","attrs":{}}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2.爲運行在計算機上的應用程序提供執行環境。","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"高級語言的應用程序是不能在裸機上運行的,必須運行再次操作系統上。","attrs":{}}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"2.崗位職責","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"2.1.用戶與硬件的接口","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"軟件接口","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"c 語言中的調用函數 print()等。","attrs":{}}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"硬件接口","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"USB 接口,串口,並口等。","attrs":{}}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"2.2.資源管理者","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/c0/c0467eff4b88bac550e0d0925a4b0420.png","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"heading","attrs":{"align":null,"level":5},"content":[{"type":"text","text":"2.2.1.管理","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"現代計算機的特點就是支持多任務,即允許在同一個系統內駐留多個應用程序。多個計算機程序共同使用計算機硬件和軟件資源的時候,就需要操作系統對這些資源進行有效管理。一方面保證用戶程序的順利執行。另一方面使計算機資源得到儘可能高效的利用。保證計算機的系統性能。","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}}],"text":"延伸 - 個人的自我管理也許需要一套適合自己的操作系統(方法論),來管理和約束自己。有效利用資源使自己的“性能”不斷提高。","attrs":{}}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":5},"content":[{"type":"text","text":"2.2.2.資源","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"處理機管理","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"程序的執行必須依賴處理機,任意時刻的處理機只能執行一個程序流。因此在單處理機的系統中執行多個程序流,必須有操作系統的處理機調度程序來管理處理機的分配,以使多個程序共享處理機,宏觀上是多個程序是同時運行。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"內存管理","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在多任務系統中,內存不在是獨佔資源,而是可能被多個應用程序共同佔用。如何爲多個應用程序分配內存並使不同的應用程序的地址空間互不干擾,如何在應用程序執行完成後回收其所佔用的內存,已完成邏輯地址到物理地址的轉換。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"設備管理","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"設備主要完成用戶的i/o 請求,爲用戶分配i/o設備,管理i/o的緩存 和驅動i/o設備等功能。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"文件管理","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"計算機系統把大量需要長時間保留的數據信息已文件的形式存放在外存設備中,操作系統需要根據自己的文件管理程序完成外存空間的分配,回收,文件的按名存取,文件的組織,共享與保護。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"3.成長曆程","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/3b/3b5d8f414f74a951200d621680f994f4.png","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"3.1.無操作系統","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"硬件環境:電子管,沒有用來存儲程序的內存。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"使用方式:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1.操作人員把作業掛到輸入設備上。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2.啓動設備。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3.運算結束取出結果。","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"例子:操作員用穿孔卡片表示程序和數據,需要運行這些穿孔卡表示作業時,程序要把卡片和交給輸入室的計算機輸入員,然後程序員等待輸出結果。計算機運行當前作業後,將計算機結果打印輸出,操作員到打印機上撕下運算結果送到輸出室,程序員可以在這裏渠道自己的運行輸出結果。","attrs":{}}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"新問題:機器速度很快的時候cpu長時間等待人工操作,造成來cpu資源的浪費。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"3.2.單道批操作系統","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"硬件環境:晶體管,開始使用磁性存儲設備,內外存容量增加。計算機的運算速度提高。","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"解決無操作系統的問題,利用磁性存儲設備提高輸入/輸出速度。同時程序常駐內存並自動裝入作業,撤銷作業,輸出運算結果。","attrs":{}}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"使用方式: ","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1.使用一臺相對偏移的,專門用來輸入的計算機把作業從穿孔卡輸入到磁帶上,一盤磁帶可以存儲多個作業。 ","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2.操作員把存有批量作業的磁帶裝入到磁帶機。 ","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3.操作員在專門技術的,性能較高的計算機上裝入早期的操作系統,也稱爲“監控程序”,它能自動從磁帶讀入作業並運行。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"4.把作業運行結果寫入專門存放輸出結果的磁帶上。 ","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"5.每當一個作業運行結束之後,操作系統自動從磁帶中讀取下一個作業並使之運行。 ","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"6.當一批作業完成後,操作員取下輸入和輸出磁帶,將輸入磁帶換成下一批作業。","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"特點:內存中只能駐留一道用戶作業,cpu 和 內存作業被用戶作業獨佔。","attrs":{}}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"新問題:在設備控制器控制設備完成輸入/輸出的一段時間內不需要 cpu 干預,此段時間內 cpu 空閒,無事可做。對於租用計算的用戶而言,損失了cpu 的機時,而計算損失了系統的吞吐量。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"3.3.多道批操作系統","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"硬件環境:集成電路","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"商業活動中一些商人嘗試生產一種通用計算機試圖把用於科學計算,工程計算及磁帶歸檔,打印處理的兩類計算機合二爲一。","attrs":{}}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"通用計算機的新問題","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1.cpu 密集型的工作 ,輸入輸出設備操作較少。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2.輸入/輸出 密集型的工作 ,cpu 等待最多產生 80%~90%浪費。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"最開始的想法:將內存分成幾個部分,每一部分存放不同的作業,當一個作業等待輸入/輸出操作完成時候,另位一個作業可以使用cpu,任何時刻,當一個作業運行完畢,操作系統會自動從外存裝入另一個作業到空閒的內存區域。這就是產生了多道批操作系統。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"新問題:早期的多到批操作系統不具備交互功能,提交作業之後,等待很長時間可能獲取的只是一個語法的error。後面就產生了分時操作系統。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"3.4.微機器操作系統","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"個人計算機","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"3.5.實時操作系統","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"支持實時計算的系統,要求規定時間內計算出 1 + 1 = 2。不僅是計算出 1 +1 =2;","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"3.6.反思與對比","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":5},"content":[{"type":"text","text":"單道批操作系統","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"自動性:自動將作業裝入內存內存運行,當運行完成後自動撤銷運行完畢的作業,並異常裝入下一個作業。使之運行。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"順序性: 按照順序依次將作業裝入內存,先裝入內存的作業先運行完畢。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"單道性:任何時刻只有一道作業","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":5},"content":[{"type":"text","text":"多道批操作系統","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"多道性:在內存中可以同時駐留多道程序,當cpu上對工作執行i/0操作時候,該cpu可以執行其他作業,從而提高系統資源的利用率和吞吐量。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"無序性:多個任務完成的順序與他們進入內存的順序之間沒有嚴格的對應關係,同時駐留內存中的作業,其獲得cpu的順序和執行的進度無法預知。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"調度性:多道程序系統必須具備作業的調度功能。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"複雜性:多道程序系統對作業共享資源的管理,作業的併發執行,及分時系統的終端用戶管理問題。因此其功能和實現計算比單到批覆雜的多。","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"優點與不足:提高 cpu,io,內存的利用率和系統的吞吐量。系統的平均運行週期長,缺乏交互能力。","attrs":{}}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":5},"content":[{"type":"text","text":"分時系統","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"分時系統是多道批系統的自然延伸,支持多任務用戶同時駐留內存,每個用戶終端與主機交互時都能得到相應。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"多路性:運行一臺主機同時存在多個連接的終端。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"獨立性:各個終端用戶彼此獨立操作,互不干擾。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"及時性:用戶在很短的時間內獲取相應。交互性:用戶可通過終端與系統進行廣泛對話。","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"優點:提供了人機交互的方便性,使多個用戶通過不同的終端共享主機。分時系統的實現解決了兩個關鍵性問題,即及時接收和及時處理。","attrs":{}}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":5},"content":[{"type":"text","text":"實時系統","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"多路性:除了具備分時系統的多路性特點外,主要表現在對多路現場信息進行採集,以及對各個對象或者執行機構進行控制。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"獨立性:具備分時系統的特點,信息的採集和對對象的控制彼此互不干擾。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"及時性:實時信息處理系統對實時性的要求是已人能接收的等待時間來確認,而實時控制系統的及時性則是已控制對象的開始時間和完成截止時間來確定的。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"交互性:實時系統的交互僅限於訪問系統某些特定的專用服務程序。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"可靠性:實時系統比分時系統更可靠。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}}],"text":"需要注意的是,批處理系統,分時系統和實時系統是三種基本的操作系統類型,而一個實際的操作系統可能兼容三者或其中兩者的功能特點。","attrs":{}}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"4.特徵展現","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"併發","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"併發是指兩個或多個事件在同一時間間隔內發生。並強調“同一時間間隔”,與並行是有區別的兩個概念,並行是指多個事件同時發生。","attrs":{}}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"共享","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"共享是指系統中的資源可供內存中多個併發的進程使用。資源共享有兩種方式:互斥共享,同時共享","attrs":{}}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"虛擬","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"是指通過某種技術把物理實體,變成若干邏輯上的對應物。","attrs":{}}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"異步性","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"進程已不可預知的速度向前推進。","attrs":{}}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"5.體系結構演變","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/ef/ef49b6f5b1e4a2979948ad774307701a.png","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"5.1.簡單的監控程序模型","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"系統功能相對簡單,任意時刻只能運行一個任務,保證了對系統的互斥訪問,保護了系統數據的安全。","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"不足:缺乏可伸縮性,任務獨佔整個系統大大降低了系統中潛在的併發性,是系統的效率嚴重受損。在設計方面缺乏結構性的指導,整個系統的所有功能全部集中在一個單一模塊中。","attrs":{}}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"5.2.單結構模型","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"所有的軟件和數據結構都放置在一個邏輯模塊中,對外出的用戶程序提供一個完整的內核界面(系統調用)。結構簡單,便於理解和實現,而系統所有部分都集中在一個內核中,效率較高。","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"不足:整個系統由若干具有獨立功能的子程序組成,系統部分之間沒有明確的位置概念,彼此沒有信息隱藏,運行一個子程序調用其他子程序。由於各個子程序之間可以相互調用,系統關係複雜,容易引起循環調用和死鎖。修改一個子程序往往導致若干相關部分的變動,系統的可修改性和可維護性較差。","attrs":{}}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"5.3.層次結構模型","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"單結構體之間的各個部分緊密依賴,互相調用,當系統模塊較多時候,無序的相互調用\b,造成系統的複雜度難以駕馭。層次結構的基本思想將系統分解爲多個小的,容易理解的層,系統功能被隔離在不同的層中,每一層提供對系統功能的部分“抽象”,然後採用單向的調用順序,形成一串彼此聯繫的對系統功能的“抽象串”,最終形成對整個功能的抽象。“分層”結構使操作系統中的各個模塊之間的組織和依賴關係清晰明瞭,系統的可讀性,可靠性,可移植性得到了增強。此外,對某一層的修改或替換隻影響臨近兩層。","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"不足:分層設計的困難之處在於如何確定各層的順序和內容,處理不好將會出現“循環依賴”問題。另外一個就是系統性能問題,有時候系統完成一個功能需要穿越多個層才能實現,系統的顆粒度越小,所花費的時間就越大。","attrs":{}}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"將所有功能模塊放在內核模型中現有不足是功能和代碼的增加結構變得複雜\b\b,這種系統的代碼變得可擴展性,可移植性,可維護性越來越差。錯誤也隨之增多。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"5.5.客戶/服務器模型與微內核","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"微內核用水平分層結構代替了原來的傳統的縱向分層的結構,這樣帶來的好處是系統結構清晰,就有較高的靈活性,可靠性,可維護性;首先只要接口規範,操作系統可以方便的增加和刪除服務功能,系統具有很好的靈活性。","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"不足:微內核的設計有一個嚴重的不足就是效率不高;微內核採用消息傳遞機制來實現組件之間的通信,消息收發的代價比傳統的操作系統要大。應爲任何消息的傳遞潛在的地方都有可能跨越系統的邊界。那麼參數需要被複制而不是從發送者的棧引用。另外,發送者和接收着消息之間的同步也增加了系統的開銷。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"改進:一,直接優化系統的消息傳遞機制。二,擴大微內核並把關鍵性服務程序和驅動程序加入到內核中從而減少系統在用戶態和核心態直接的切換。","attrs":{}}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"微內核技術是現在操作系統額一個發展趨勢,結合面向對象設計的方法,微內核具有更多地應用空間。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"5.6.動態可擴展結構模型","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" 20世界80年代提出,基本思想是在運行過程中,能夠動態實現系統的行爲擴展。具體實現動態可擴展結構,首先要解決的問題就是如何實現系統行爲的動態改變。目前實現的方式就是通過動態的增刪除系統中代碼,採用的主要技術由 UPCALL 和 DOWNLOAD。(元編程的感覺)","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"UPCALL 技術是指在微內核操作系統中通過核心層到用戶層的調用方式來擴展的技術。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"DOWNLOAD技術的核心思想就是將軟件構件動態下載到內核中,以達到改變操作系統的目的。","attrs":{}}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"以上爲 《重拾操作系統》系列的第一篇\"成長之路\",歡迎大家的留言討論。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"italic","attrs":{}},{"type":"size","attrs":{"size":12}},{"type":"strong","attrs":{}}],"text":"最後用《愛麗絲夢遊仙境》裏紅皇后對愛麗絲的一句話與大家共勉【你必須盡力不停的跑,才能使你保持在原地】。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#40A9FF","name":"blue"}}],"text":"今天北京的天氣太應景了,還是把這篇文章發了吧!","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/31/31d9a63532d5643b903f02529afd06f2.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章