混合內核
混合內核(英語:Hybrid kernel),又譯為混合式內核,一種作業系統內核架構。傳統上的作業系統內核可以分為整塊性內核(Monolithic kernel)與微內核(Micro kernel)兩大基本架構,混合內核結合了這兩種內核架構。


混合內核的基本設計理念,是以微內核架構來設計作業系統內核,但在實作上則採用整塊性內核的作法。混合內核實質上是微內核,只不過它讓一些微核結構執行在用戶空間的代碼執行在內核空間,這樣讓內核的執行效率更高些。這是一種妥協做法,設計者參考了微內核結構的系統執行速度不佳的理論。
大多數現代作業系統遵循這種設計範疇,是用微內核的概念來設計,但是實作上則採用整塊性內核的作法,結合整塊性內核(Monolithic kernel)與微內核(Micro kernel)兩種設計方法,形成第三種分類。但是這種分類法受到一些批評,如林納斯·托瓦茲認為這種分類只是一種市場行銷手法,因為它的架構實作方式接近於整塊性內核[1]。
最有名的混合內核為Windows NT內核與XNU。
概論
編輯這個設計方式是一種妥協下的設計。在設計理念上,採用微內核架構來設計,但因為微內核結構一直被批評為效能不佳,因此在實作上,則採用整塊性內核的作法。微內核架構將作業系統服務(task server)運行在用戶空間,以保證系統的穩定可靠。與典型的微內核設計相較,在混合內核中,多數的作業系統服務(task server)仍然運行在內核空間中,與整塊性內核相同。因為讓作業系統服務運行在內核空間,減少了訊息傳遞及環境切換(content switch)帶來的系統負擔,這可以避免微內核架構常被批評的效能不佳問題;但也因此,這種設計無法提供微內核系統架構下的穩定性保證。
批評
編輯林納斯·托瓦茲認為,採用可載入內核模組不代表這個作業系統就是一種混合內核,如果模組跟內核使用同樣的定址空間,能夠存取內核的資料結果,這種實作方式就是整塊性內核[2]。以這種定義來看,混合內核實際上是整塊性內核的變種。
例子
編輯NT內核
編輯XNU內核
編輯其他
編輯- BeOS內核
- DragonFly BSD
- ReactOS內核
參見
編輯註釋
編輯- ^ Linus Torvalds. [2018-06-13]. (原始內容存檔於2021-01-09).
As to the whole "hybrid kernel" thing - it's just marketing. It's "Oh, those microkernels had good PR, how can we try to get good PR for our working kernel? Oh, I know, let's use a cool name and try to imply that it has all the PR advantages that that other system has.
- ^
The article goes to say that a hybrid kernel like NT's is not to be confused with a with monolithic kernels that can load modules like Linux. Again, this seems like nonsense to me - the stable driver ABI (and the closed source) has facilitated creating of many drivers outside of the NT kernel tree, but this is not a conceptual difference. The precise technique of loading a driver/module into the kernel doesn't really matter, if the driver shares the same address space and can have access to kernel structures.