⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lib0047.html

📁 Memory Management—Algorithms and implementation in C/C++ Introduction Chapter 1 - Memory Manag
💻 HTML
字号:
<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Monolithic Versus Microkernel Architectures</title>
<link rel="STYLESHEET" type="text/css" href="images/xpolecat.css">
<link rel="STYLESHEET" type="text/css" href="images/ie.content.books24x7.css">
</head>
<body >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<td><div STYLE="MARGIN-LEFT: 0.15in;">
<a href="toc.html"><img src="images/teamlib.gif" width="62" height="15" border="0" align="absmiddle"  alt="Team LiB"></a></div></td>
<td valign="top" class="v2" align="right"><div STYLE="MARGIN-RIGHT: 0.15in"><a href="LiB0046.html"><img src="images/previous.gif" width="62" height="15" border="0" align="absmiddle" alt="Previous Section"></a>
<a href="LiB0048.html"><img src="images/next.gif" width="41" height="15" border="0" align="absmiddle" alt="Next Section"></a>
</div></td></tr>
</table>

<div class="chapter">
<a name="ch06"></a>
<div class="section">
<h2 class="first-section-title"><a name="646"></a><a name="ch06lev1sec2"></a>Monolithic Versus Microkernel Architectures</h2><p class="first-para">All of the operating systems that we looked at in <a href="LiB0019.html#131" target="_parent" class="chapterjump">Chapter 2</a> were <i class="emphasis">monolithic</i>, which is to say that all the components of the operating system (the task scheduler, the memory manager, the file system manager, and the device drivers) exist in a common address space and everything executes in kernel mode (at privilege level 0). In other words, a monolithic operating system behaves like one big program. UNIX, Linux, MMURTL, DOS, and Windows are all monolithic operating systems.</p>
<p class="para">Another approach to constructing an operating system is to use a <i class="emphasis">microkernel</i> design. With a microkernel operating system, only a small portion of the operating system functions in kernel mode. Typically, this includes task scheduling, interrupt handling, low-level device drivers, and a message-passing subsystem to provide interprocess communication primitives. The rest of the operating system components, like the memory manager and the file system manager, run as separate tasks in user space and communicate with each other using the kernel's message passing facilities. MINIX, Mach, and Chorus are examples of microkernel operating systems.</p>
<p class="para">The difference between monolithic and microkernel architectures is displayed in <a class="internaljump" href="#ch06fig02">Figure 6.2</a>.</p>
<div class="figure">
<a name="647"></a><a name="ch06fig02"></a><span class="figuremediaobject"><a href="images/fig377%5F01%5F0%2Ejpg" NAME="IMG_98" target="_parent"><img src="images/fig377_01.jpg" height="196" width="286" alt="Click To expand" border="0"></a></span>
<br style="line-height: 1">
<span class="figure-title"><span class="figure-titlelabel">Figure 6.2</span></span>
</div>
<p class="para">The researchers supporting the microkernel school of thought claim that the enforcement of modular operating system components provides a cleaner set of interfaces. This characteristic, in turn, makes it easier to maintain and modify an operating system. Operating systems are often judged with regard to how well they accommodate change. The operating systems that tend to survive are the ones that are easy to extend and enhance. By allowing core <a name="648"></a><a name="IDX-349"></a>components to be separate tasks running at user level, different implementations can be switched in and out very easily.</p>
<p class="para">Furthermore, microkernel proponents also claim that their approach provides better system stability. For example, if the memory manager is faced with a terminal error, instead of bringing down the entire operating system the memory management user task exists. This gives the microkernel the opportunity to recover gracefully from what might ordinarily be a disaster.</p>
<p class="para">In the early 1990s, Torvalds and Tanenbaum became involved in a flame war. This well-known debate was initiated by Tanenbaum when he posted a message to <span class="fixed">comp.os.minix</span> entitled "Linux is obsolete." In his original message, Tanenbaum mentioned:</p>
<blockquote class="blockquote">
<p class="first-para">"Don't get me wrong, I am not unhappy with LINUX. It will get all the people who want to turn MINIX in BSD UNIX off my back. But in all honesty, I would suggest that people who want a **MODERN** "free" OS look around for a microkernel-based, portable OS, like maybe GNU or something like that."</p>
</blockquote>
<p class="para">"Modern" OS &mdash; my goodness, that sounds a tad arrogant to me.</p>
<p class="para">The resulting flame-fest progressed over several messages, each side attacking the other's logic and world view. Although Tanenbaum did raise some interesting points in his debate with Torvalds, history sides with Torvalds. MINIX has been relegated to a footnote in history and Linux has a user base of millions.</p>
<a name="649"></a><a name="IDX-350"></a>
<p class="para">As I stated in <a href="LiB0012.html#49" target="_parent" class="chapterjump">Chapter 1</a>, speed rules the commercial arena. Darwin's laws definitely apply to the software arena. Those operating systems that possess attributes that make them useful in production environments will be the ones that survive. The successful operating systems that are currently the big money makers for software vendors, like Microsoft, HP, Sun, and IBM, are monolithic (i.e., Windows, HP-UX, Solaris, and zOS).</p>
<p class="para">One problem that plagues microkernel implementations is relatively poor performance. The message-passing layer that connects different operating system components introduces an extra layer of machine instructions. The machine instruction overhead introduced by the message-passing subsystem manifests itself as additional execution time. In a monolithic system, if a kernel component needs to talk to another component, it can make direct function calls instead of going through a third party.</p>
<table border="0" cellspacing="0" cellpadding="0" class="note">
<tr>
<td valign="top" class="admon-check"></td><td valign="top" class="admon-title">Note&nbsp;</td><td valign="top" class="admon-body">
<p class="first-para">A classic example of the performance hit associated with pushing functionality to user space is X Windows. Linux does not have a significant amount of user-interface code in the kernel. This affords Linux a modicum of flexibility because the kernel has not committed itself to any particular GUI implementation. Linux can run GNOME, KDE, and a number of other GUIs. The problem, however, is that everything happens in user space, and this entails a nasty performance hit. Windows, on the other hand, has pushed a hefty amount of the GUI management code down to the kernel, where interaction with hardware is more expedient. Specifically, most of Windows GUI code is contained in the <span class="fixed">Win32k.sys</span> kernel mode device driver.</p>
</td>
</tr>
</table>
<p class="para">Security problems are another issue with microkernel designs. Because core operating system components exist in user space, they have less protection than the kernel. I imagine that it would be possible to subvert a given system manager by creating a duplicate task that hijacks the message stream between the kernel and the existing component. Microkernel advocates may also claim that their designs are more stable, but I doubt that an operating system could survive if its memory management unit called it quits.</p>
<p class="para">Finally, most production operating system implementations are huge. According to a July 29, 1996, <I>Wall Street Journal</I> article, Windows NT 4.0 consists of over 16.5 million lines of code. I would speculate that Windows XP may very well have doubled that number. With a code base in the millions, I am not sure if the organizational benefits provided by a microkernel design would really make that much of a difference. On this scale, internal conventions and disciplined engineering would probably have a greater impact on maintainability.</p>
<a name="650"></a><a name="IDX-351"></a>
<p class="para">In other words, it is not exactly what you are building but how you build it that makes the difference between success and failure.</p>
<p class="para">
<a class="internaljump" href="#ch06table01">Table 6.1</a> presents a comparison of monolithic and microkernel design approaches.</p>
<a name="651"></a><a name="ch06table01"></a>
<table class="table" border="1">
<caption class="table-title">
<span class="table-title"><span class="table-titlelabel">Table 6.1</span></span>
</caption>
<thead>
<tr valign="top">
<th class="th" scope="col" align="left">&nbsp;</th><th class="th" scope="col" align="left">
<p class="table-para">
<b class="bold">Monolithic</b>
</p>
</th><th class="th" scope="col" align="left">
<p class="table-para">
<b class="bold">Microkernel</b>
</p>
</th>
</tr>
</thead>
<tbody>
<tr valign="top">
<td class="td" align="left">
<p class="table-para">
<b class="bold">Maintainability</b>
</p>
</td><td class="td" align="left">
<p class="table-para">complicated interaction</p>
</td><td class="td" align="left">
<p class="table-para">marginally better</p>
</td>
</tr>
<tr valign="top">
<td class="td" align="left">
<p class="table-para">
<b class="bold">Stability</b>
</p>
</td><td class="td" align="left">
<p class="table-para">kernel errors lead to crash</p>
</td><td class="td" align="left">
<p class="table-para">questionable isolation of errors</p>
</td>
</tr>
<tr valign="top">
<td class="td" align="left">
<p class="table-para">
<b class="bold">Performance</b>
</p>
</td><td class="td" align="left">
<p class="table-para">faster</p>
</td><td class="td" align="left">
<p class="table-para">slower, messaging overhead</p>
</td>
</tr>
<tr valign="top">
<td class="td" align="left">
<p class="table-para">
<b class="bold">Security</b>
</p>
</td><td class="td" align="left">
<p class="table-para">everything in kernel mode</p>
</td><td class="td" align="left">
<p class="table-para">core components in user mode</p>
</td>
</tr>
</tbody>
</table>
<a></a>
</div>
</div>
</div>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<td><div STYLE="MARGIN-LEFT: 0.15in;">
<a href="toc.html"><img src="images/teamlib.gif" width="62" height="15" border="0" align="absmiddle"  alt="Team LiB"></a></div></td>
<td valign="top" class="v2" align="right"><div STYLE="MARGIN-RIGHT: 0.15in"><a href="LiB0046.html"><img src="images/previous.gif" width="62" height="15" border="0" align="absmiddle" alt="Previous Section"></a>
<a href="LiB0048.html"><img src="images/next.gif" width="41" height="15" border="0" align="absmiddle" alt="Next Section"></a>
</div></td></tr>
</table>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -