微内核VS单体内核

<!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:1.0pt;} p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {mso-style-priority:34; mso-style-unhide:no; mso-style-qformat:yes; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; text-indent:21.0pt; mso-char-indent-count:2.0; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:1.0pt;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:308486891; mso-list-type:hybrid; mso-list-template-ids:2078571490 67698697 67698697 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l0:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:21.0pt; text-indent:-21.0pt; font-family:Wingdings;} @list l0:level2 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:42.0pt; text-indent:-21.0pt; font-family:Wingdings;} @list l1 {mso-list-id:1648707365; mso-list-type:hybrid; mso-list-template-ids:1273920154 -672776708 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l1:level1 {mso-level-tab-stop:none; mso-level-number-position:left; margin-left:18.0pt; text-indent:-18.0pt;} ol {margin-bottom:0cm;} ul {margin-bottom:0cm;} -->

1.      单体内核 VS 微内核

当前流行的操作系统内核的设计方式中,一称为单体内核,又称为宏内核,也就是说内核本身只是一个程序,而内核所有的功能都是链接在这个程序的内部,如果某个进程要使用某个功能的话,将是进入内核空间,然后调用相对应的功能函数来实现的。一般我们所常见的 Unix 系统都是采用单体内核的方式设计的,比如传统的 UNIX, 现在大行其道的 Linux, 以及商业化非常成功的 SUN Microsystem 推出的 Solaris

当一个操作系统内核作为一个程序的时候,有着许多的不足之处。我们都知道驱动程序是工作在内核中的,当前设计硬件的厂商多余牛毛,每一种硬件设备都必须配以驱动程序,而在单体内核的设计中,驱动程序又必须是和操作系统内核编译在一起的,硬件设备更新日新月异,每天都有新的硬件出现,每天都有更新版本的驱动产生,这样操作系统的发行商为了支持这些硬件每天都在编译新的操作系统内核,然后重新发布操作系统,这何其烦也?而且操作系统内核镜像文件会变的何其庞大?

其二,单体内核的操作系统镜像是作为一个程序运行的,并且是常驻在物理内存之中,当你安装并运行了这个操作系统后,你会发现你系统的物理资源都完全被你根本就没有,或者一辈子都适用不到的硬件设备的驱动程序占据着,而留给你的资源却寥寥无几,此时你有何感想?

微内核,恰恰不会吹灰之力就解决的上述的问题。

微内核是在上个世纪七八十年代提出来的一种操作系统的设计方式,微内核本身只提供最基本的操作系统的功能,比如进程调度与消息传递等,其他的功能由其独立的模块提供,每个独立的功能模块都可以是一个进程。当我们需要使用某个功能的时候,我们只需要在运行的操作系统里安装这个模块,并且运行对应服务,当这个功能不再需要的时候,我们可以停止这个服务,这样这个功能模块将不占据系统内存和处理器的资源,而不会破坏当前的系统正常运行,各功能模块与微内核之间是彼此独立的,这样即使功能模块崩溃的时候,系统也不至于挂机。

当一个进程如果需要使用某个功能,就会向微内核发一个消息请求,微内核转发这个请求到对应的功能模块的进程,然后把结果通过微内核再返回给请求进程。如果这个功能模块不存在,那么这个请求也将失败。此时我们可以在系统运行的情况下,安装这个功能模块,可能是一个驱动,也可能是一个服务进程。这样这个模块就可以为其他进程服务了。

         所以,微内核设计方式带来的优势:

ü  模块化的方式设计操作系统,模块的设计者只需要关注自己的功能模块。

ü  操作系统的更新时,除了微内核本身,可以动态的更新其他的功能模块

ü  在系统运行的时候,可以根据需要动态的使能 / 禁止对应的模块,以释放计算机的资源。

当前商业上使用较多的微内核方式设计的操作系统有风靡全球的 Windows 系统,用于图像处理的 Mac OS 系统,以及在实时嵌入式领域独领风骚的 WindRiver VxWorks 系统。

从上面的描述看来,模块化设计的微内核操作系统似乎是大势所趋,但是单体内核方式设计的 Linux, Solaris 却未在市场竞争中甘拜下风? 这是为何呢?

         深入研究,就会发现,其一,微内核在性能上有不可避免的弱点,因为一个进程需要使用某个功能模块的时候,需要通过消息机制来传输。这里涉及到消息传递进程切换的时间,这比函数调用的消耗大的多。其二, Unix 的程序员向来都是天赋甚高的一类怪才,灵机一动,就会想到难道在单体内核中就不能实现类似于微内核的模块的方法吗?

         答案当然是肯定的,可以,这样我们既满足了动态的添加功能模块,删除功能模块,又可以利用函数调用带来性能上的优势。下面一节,我们就初窥 Linux 内核模块的行径。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值