鴻蒙 和 Fuchsia OS,你更期待誰?

{"type":"doc","content":[{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"大家好,我是小Bob,一個關注軟件領域而又執着於計算機底層的開發者~","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":"在月初,華爲的鴻蒙系統HarmonyOS 2.0已發佈,給我最直接的感受便是真正的","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"萬物互聯","attrs":{}},{"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}},{"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":"那麼對於華爲的鴻蒙HarmonyOS2.0以及在它之前一週左右Google推出的Fuchsia OS到底有什麼新的","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"Idea","attrs":{}},{"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":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"物聯網","attrs":{}},{"type":"text","text":"的基因,那麼小編便針對於兩者的技術進行簡單分析。","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/54/54a109ee09338ec4e27eee9a1ff095ba.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}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":1},"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","text":"首先,對於華爲的鴻蒙HarmonyOS2.0,按照","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"百度","attrs":{}},{"type":"text","text":"的說法:華爲鴻蒙系統是一款全新的面向全場景的分佈式操作系統,創造一個超級虛擬終端互聯的世界,將人、設備、場景有機地聯繫在一起,將消費者在全場景生活中接觸的多種智能終端實現極速發現、極速連接、硬件互助、資源共享,用合適的設備提供場景體驗。","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":"通過華爲最新的視頻我們也可以看到鴻蒙將手機、電腦、平板、智能家居進行實時同步,不得不說,還是挺震撼的。據華爲說鴻蒙是基於微內核開發,面向5G、面向全場景的分佈式系統。那麼問題來了,什麼是微內核呢?它和安卓的底層有什麼不同嗎?","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"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":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"尋址空間管理、線程管理、與進程間通信。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"微核心的設計理念:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"是將系統服務的實現,與系統的基本操作規則區分開來。它實現的方式,是","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"將核心功能模塊化","attrs":{}},{"type":"text","text":",劃分成幾個獨立的進程,各自運行,這些進程被稱爲服務。所有的服務進程,都運行在不同的地址空間。只有需要絕對特權的進程,才能在具特權的運行模式下運行,其餘的進程則在用戶空間運行。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"微內核的基本原理:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"只有最基本的操作系統功能才放入內核中。非基本的服務和應用程序在內核之上構建,並在用戶模式下運行。關於什麼功能應該放入微內核,不同的設計有不同的方式,但是共同特點是許多傳統上屬於操作系統一部分的功能現在都是外部子系統,包括","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"設備驅動程序","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}}],"text":",","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"文件系統","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}}],"text":",","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"虛存管理程序","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}}],"text":",","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"窗口系統","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}}],"text":"和","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"安全服務","attrs":{}},{"type":"text","text":",它們可以和內核交互,也可以相互交互。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":"center","origin":null},"content":[{"type":"text","text":"摘錄一張經典的對比操作系統","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}}],"text":"微內核和宏內核","attrs":{}},{"type":"text","text":"的圖示:","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/fe/fe38a079a079903bacd9c91c6671e47c.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":"center","origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"比如我們經常使用的Windows,便是採用的混合內核。","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}},{"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":"image","attrs":{"src":"https://static001.geekbang.org/infoq/95/959f3894f650f715869453c9665bb6d4.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}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"微內核的性能:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"underline","attrs":{}},{"type":"color","attrs":{"color":"#F5222D","name":"red"}}],"text":"通過微內核構造和發送消息,比直接進行一次系統調用發花費更多時間。","attrs":{}},{"type":"text","text":"一種解決方式是將一些關鍵服務和驅動程序重新放回內核中,可以減少用戶-內核模式以及進程間的切換次數,但是這是以犧牲微內核的設計強度爲代價;另一種解決方式是通過正確的設計,構造一個非常小的內核,可以消除消除性能損失並提高靈活性。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"微內核設計:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"低級存儲器管理","attrs":{}},{"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":"image","attrs":{"src":"https://static001.geekbang.org/infoq/47/4719343ea4ed0e555b9ca525371b4432.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}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"這種技術可以不用調用內核操作,就將文件和數據庫映射到用戶地址空間。","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"微內核一共提供了三個內核操作用於支持核外的分頁和虛存管理:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"numberedlist","attrs":{"start":1,"normalizeStart":1},"content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":1,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"授權","attrs":{}},{"type":"text","text":":一個地址空間的所有者可以授權其他進程使用它的某些頁。內核把這些頁從授權者的地址空間移出,並把它們分配給指定的進程;","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":2,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"映射","attrs":{}},{"type":"text","text":":一個進程可以把它的任何頁映射到另一個進程的地址空間,使得兩個進程都可以訪問這些頁,就形成了共享內存。內核把這些頁面分配給最初的所有者,爲其他進程   提供一個映射以便訪問它們;","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":3,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"刷新","attrs":{}},{"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":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"進程間的通信","attrs":{}},{"type":"text","text":":微內核操作系統中,進程之間或者線程之間進行通信的基本方式是","attrs":{}},{"type":"text","marks":[{"type":"underline","attrs":{}},{"type":"strong","attrs":{}}],"text":"消息","attrs":{}},{"type":"text","text":"。","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"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","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}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"I/O和中斷管理","attrs":{}},{"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}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"Google之Fuchsia OS","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","text":"谷歌近日正式面向公衆推出了 Fuchsia OS,獲得Fuchsia 1.0 推送的設備是第一代 Nest Hub。","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":"Fuchsia OS與安卓不同的是它使用了全新的、自研的 Zircon 微內核,其採用 C++ 編寫。內核的組件則使用到了 Go、Rust、Python,以及 C/C++ 等編程語言進行編寫,如 USB 驅動程序使用 C++ 編寫,而網絡堆棧則使用了 Rust。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/0b/0b645e0fb96dcd1d6073039ef2a6f0d1.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"什麼是Zircon呢?","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":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"Zircon作爲uFuchsia系統的內核。","attrs":{}},{"type":"text","text":"嚴格的講,應該說Zircon是Fuchsia系統的核心,是Fuchsia系統的最底一層。它由一個微內核(/zircon/kernel)和少量的用戶空間代碼組成。這部分用戶空間代碼是一些核心的服務、驅動和類庫等(/zircon/system/necessary),用於系統引導,與底層硬件交互、加載用戶空間的進程等。","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":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"Zircon對外提供系統調用,用來管理進程、線程、虛擬內存等,提供進程間通信的機制,監控內核中對象狀態的改變,提供鎖機制等。","attrs":{}},{"type":"text","text":"內核管理了大量的各種類型的對象,用戶空間可以通過系統調用直接讀取這些對象,這些東西通常是實現了分發接口的C++對象。這些C++類定義在kernel/object目錄下,這些類大部分是一些自包含的C++類,一部分是底層LK(little kernel zircon內核的內核,一個嵌入式的內核)原語的包裝類。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"Fuchsia OS如何工作?","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Google在開發Fuchsia OS方面開闢了新天地。可以說,該公司從過去的錯誤中吸取了教訓,尤其是在更新和修改Android和Chrome OS的侷限性和問題方面。與已建立的Google操作系統的主要區別:","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"Fuchsia OS從頭到尾都是模塊化的。這不僅反映在模塊化系統體系結構中,而且反映在對應用程序是什麼的全新理解中。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"模塊化應用設計","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}}],"text":"Google Fuchsia基於模塊化設計,打破了應用程序的概念。","attrs":{}},{"type":"text","text":"軟件單元稱爲","attrs":{}},{"type":"text","marks":[{"type":"italic","attrs":{}}],"text":"軟件包","attrs":{}},{"type":"text","text":"。","attrs":{}},{"type":"text","marks":[{"type":"italic","attrs":{}}],"text":"軟件包","attrs":{}},{"type":"text","text":"是一個被選中的文件—包括元數據、清單文件和可執行元素。後者在Google術語中稱爲","attrs":{}},{"type":"text","marks":[{"type":"underline","attrs":{}}],"text":"組件","attrs":{}},{"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":"strong","attrs":{}}],"text":"Fuchsia 組件最接近我們今天所說的應用程序。","attrs":{}},{"type":"text","text":"每個組件執行特定任務,並且可以與其他組件組合以編程一個更復雜的應用程序。組件由清單文件以及相關的代碼組成。組件始終在自己的沙箱中運行,通過名稱空間訪問對象,並通過導出目錄發佈它們。","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"Fuchsia OS專注於兩種類型的組件:","attrs":{}},{"type":"text","marks":[{"type":"italic","attrs":{}},{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"模塊","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"(","attrs":{}},{"type":"text","marks":[{"type":"italic","attrs":{}},{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"modules","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":" )和","attrs":{}},{"type":"text","marks":[{"type":"italic","attrs":{}},{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"代理","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"(","attrs":{}},{"type":"text","marks":[{"type":"italic","attrs":{}},{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"agents","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"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":"strong","attrs":{}}],"text":"agents","attrs":{}},{"type":"text","text":"組件在後臺工作,併爲其他組件提供服務。","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"agents由另一個組件或系統調用-例如,響應某些觸發(例如推送通知或其他屏幕處理)。","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":"strong","attrs":{}}],"text":"modules","attrs":{}},{"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":"text","marks":[{"type":"strong","attrs":{}}],"text":"verbs 列表","attrs":{}},{"type":"text","text":",表示模塊可以執行的工作,以及一個","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"nouns 列表","attrs":{}},{"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":"strong","attrs":{}}],"text":"因此,","attrs":{}},{"type":"text","text":"使用實時操作系統Fuchsia的方式如下:","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"用戶執行操作後,Fuchsia OS會自動爲該任務確定適當的模塊。所需的動作被翻譯成動詞和名詞的組合。然後,系統檢索所有支持所需動詞的模塊的列表,並在下一步中根據還可以處理所需名詞的模塊進行過濾。","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":"text","marks":[{"type":"strong","attrs":{}}],"text":"stories","attrs":{}},{"type":"text","text":"中。","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"stories","attrs":{}},{"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":"藉助Fuchsia OS的模塊化應用程序概念,Google將重點從應用程序轉移到動作和內容。Fuchsia 的任務由所謂的","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"stories","attrs":{}},{"type":"text","text":"中的一組組件來處理,而不是當前使用的應用程序的經典操作系統,該組件通過模塊訪問當前所需的資源。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":"center","origin":null},"content":[{"type":"text","text":"下圖說明了Fuchsia OS應用程序開發背後的模塊化概念。","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/1b/1ba718888c64c4fef9b58c4d50ade543.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}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":"center","origin":null},"content":[{"type":"text","text":"Fuchsia OS的應用程序開發基於模塊化結構。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"模塊化系統架構","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"Fuchsia OS的系統架構也基於模塊化方法。操作系統由四個或多或少的獨立級別組成,每個級別都有其自己的任務:Zircon,Garnet,Peridot和Topaz。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"Zircon","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"Zircon(以前爲Magenta)是新的Google操作系統的基礎,但嚴格來說,它不是Fuchsia OS的一部分,也可以與其他操作系統一起使用。","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":"strong","attrs":{}}],"text":"Zircon包含Fuchsia OS的內核,設備管理器,最核心的第一層設備驅動程序以及底層系統庫(如libc和launchpad)。","attrs":{}},{"type":"text","text":"此外,Zircon還提供FIDL(Fuchsia 接口定義語言),這是一種用於進程間通信的協議。FIDL是獨立於編程語言的,但是與流行的編程語言(例如C,C ++,Dart,Go和Rust)具有聯繫。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"作爲Fuchsia OS的基礎,Zircon提供了對後續級別的硬件訪問,在共享硬件資源上創建了軟件抽象,並充當了低級軟件開發的平臺。Zircon是Project Little Kernel(LK)的結果,該項目充當Android的引導程序。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"Garnet","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"Garnet是基於Zircon的第一款針對Fuchsia 的系統層。","attrs":{}},{"type":"text","text":"提供了設備級別的各種系統服務以及網絡,媒體和圖形服務,例如,用於軟件安裝,系統管理以及與其他系統的通信。Garnet包含圖形渲染器Escher,程序包管理和更新系統","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"Amber","attrs":{}},{"type":"text","text":"以及文本和代碼編輯器Xi。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"Peridot","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"Peridot是Fuchsia OS的操作系統級別,根據當前用戶要求在其上管理和編譯模塊化應用程序。","attrs":{}},{"type":"text","text":"Peridot的核心成分是Ledger和Maxwell。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"Ledger","attrs":{}},{"type":"text","text":":Ledger是基於雲的存儲系統(分佈式存儲系統),它爲每個Fuchsia組件(模塊或代理)提供單獨的數據存儲。這在不同設備之間同步。這使用戶可以在當前Fuchsia 的設備上繼續停留在其他Fuchsia 的設備上的位置。","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"Maxwell","attrs":{}},{"type":"text","text":":通過Maxwell,Google在Fuchsia OS中集成了一個組件,該組件將給用戶提供了人工智能。就像Fuchsia 一樣,Maxwell具有模塊化設計。AI系統由一系列代理組成,這些代理分析用戶的行爲及其所使用的內容,在後臺確定合適的信息,並將建議轉發給操作系統-例如,應加載哪些模塊或故事以適合用戶在特定時間的行爲。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"italic","attrs":{}}],"text":"注意:到目前爲止,Kronk是Fuchsia OS唯一未作爲開源項目開發的組件。","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"Topaz","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}},{"type":"strong","attrs":{}}],"text":"Topaz是Fuchsia OS的系統級別,用戶可以在其中與操作系統進行交互。","attrs":{}},{"type":"text","text":"在此顯示以下級別定義的組件的用戶界面:帶主屏幕的圖形用戶界面(取決於設備Armadillo或Capybara)以及模塊的可視前端。Google的跨平臺開源移動應用程序框架Flutter也已在此係統級別集成。因此,可以假定Fuchsia OS用戶將來也將能夠運行和使用其他系統的應用程序,例如Android或iOS應用程序。","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/73/7368749e509f57f4b0de294f7ad58b1b.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":"center","origin":null},"content":[{"type":"text","marks":[{"type":"italic","attrs":{}}],"text":"Fuchsia OS的四個系統級別:Zircon, Garnet, Peridot, and Topaz","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}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"參考資料","attrs":{}},{"type":"text","text":":","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://segmentfault.com/a/1190000039919439","title":null,"type":null},"content":[{"type":"text","text":"鴻蒙系統(HOS)終於上線,微內核操作系統科普","attrs":{}}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://segmentfault.com/a/1190000038447862","title":null,"type":null},"content":[{"type":"text","text":"Fuchsia OS ——未來的Google操作系統?","attrs":{}}]}]}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章