混合内核

混合内核英语:),又译为混合式内核混合内核,一种操作系统内核架构。传统上的操作系统内核可以分为整块性内核(Monolithic kernel)与微内核(Micro kernel)两大基本架构,混合内核结合了这两种内核架构。

混合内核的示意图
分别为宏内核、微内核、混合内核的操作系统结构

混合内核的基本设计理念,是以微内核架构来设计操作系统内核,但在实作上则采用整块性内核的作法。混合内核实质上是微内核,只不过它让一些微核结构运行在用户空间的代码运行在内核空间,这样让内核的运行效率更高些。这是一种妥协做法,设计者参考了微内核结构的系统运行速度不佳的理论。

大多数现代操作系统遵循这种设计范畴,是用微内核的概念来设计,但是实作上则采用整块性内核的作法,结合整块性内核(Monolithic kernel)与微内核(Micro kernel)两种设计方法,形成第三种分类。但是这种分类法受到一些批评,如林纳斯·托瓦兹认为这种分类只是一种市场行销手法,因为它的架构实作方式接近于整块性内核[1]

最有名的混合内核为Windows NT内核与XNU

概论

这个设计方式是一种妥协下的设计。在设计理念上,采用微内核架构来设计,但因为微内核结构一直被批评为性能不佳,因此在实作上,则采用整块性内核的作法。微内核架构将操作系统服务(task server)运行在用户空间,以保证系统的稳定可靠。与典型的微内核设计相较,在混合内核中,多数的操作系统服务(task server)仍然运行在内核空间中,与整块性内核相同。因为让操作系统服务运行在内核空间,减少了消息传递及环境切换(content switch)带来的系统负担,这可以避免微内核架构常被批评的性能不佳问题;但也因此,这种设计无法提供微内核系统架构下的稳定性保证。

批评

林纳斯·托瓦兹认为,采用可加载内核模块不代表这个操作系统就是一种混合内核,如果模块跟内核使用同样的寻址空间,能够访问内核的数据结果,这种实作方式就是整块性内核[2]。以这种定义来看,混合内核实际上是整块性内核的变种。

例子

NT内核

XNU内核

  • macOS(前称Mac OS X及OS X,使用FreeBSD原代码和Mach内核来实作)
  • XNU(使用Mach内核)

其他

参见

注释

  1. . [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.
  2. 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.
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.