The following list describes how Linux competes against some well-known commercial Unix kernels: Monolithic kernel It is a large, complex do-it-yourself program, composed of several logically different components. In this, it is quite conventional; most commercial Unix variants are monolithic. (Notable exceptions are the Apple Mac OS X and the GNU Hurd operating systems, both derived from the Carnegie-Mellon’s Mach, which follow a microkernel approach.) Compiled and statically linked traditional Unix kernels Most modern kernels can dynamically load and unload some portions of the kernel code (typically, device drivers), which are usually called modules. Linux’s support for modules is very good, because it is able to automatically load and unload modules on demand. Among the main commercial Unix variants, only the SVR4.2 and Solaris kernels have a similar feature. Kernel threading Some Unix kernels, such as Solaris and SVR4.2/MP, are organized as a set of kernel threads. A kernel thread is an execution context that can be independently scheduled; it may be associated with a user program, or it may run only some kernel functions. Context switches between kernel threads are usually much less expensive than context switches between ordinary processes, because the former usually operate on a common address space. Linux uses kernel threads in a very limited way to execute a few kernel functions periodically; however, they do not represent the basic execution context abstraction. (That’s the topic of the next item.) Multithreaded application support Most modern operating systems have some kind of support for multithreaded applications—that is, user programs that are designed in terms of many relatively independent execution flows that share a large portion of the application data structures. A multithreaded user application could be composed of many lightweight processes (LWP), which are processes that can operate on a common address space, common physical memory pages, common opened files, and so on. Linux defines its own version of lightweight processes, which is different from the types used on other systems such as SVR4 and Solaris. While all the commercial Unix variants of LWP are based on kernel threads, Linux regards lightweight processes as the basic execution context and handles them via the nonstandard clone() system call.
以下列出了Linux能够和那些广为人知的商用操作系统比肩的理由: 宏内核结构 Linux内核是一个庞大而复杂的DIY程序,由几个逻辑上不同的部件组成。在这一点上它是非常传统的,大多数商用Unix变种操作系统都是单块结构的。(值得注意的是苹果的Mac OS X和GNU Hurd操作系统,它们都是基于由卡耐基梅隆大学的Mach实现,Mach采用的则是微内核结构。) 采用编译式和静态链接式的传统的Unix内核 大多数现代内核都能够动态加载和卸载内核源码的部分组件(典型的是设备驱动),通常称这些组件为模块。Linux对模块的支持非常灵便,因为它可以根据需要自动地加载和卸载模块。在主流的商用操作Unix变种操作系统中只有SVR4.2和Solaris内核具有类似的特性。 内核线程 像Solaris和SVR4.2/MP这样的一些Unix内核是被当作一组内核线程组织起来的。一个内核线程是一个可以独立完成调度的执行上下文;一个内核线程可能和一个用户程序关联起来,也可能仅运行一部分内核函数。内核线程之间的上下文切换往往比普通的进程之间的切换更划算(消耗的资源更少——译者按),但是内核线程的上下文切换并不意味着基本的可执行上下文进行了抽象。(这是接下来要讨论的问题) 支持多线程应用 大多数的现代操作系统都有一些支持多线程应用的手段——那就意味着用户程序可以设计成许多相互独立同时相互关联的可执行流,这些可执行流共享程序的大部分数据结构。一个多线程的应用程序可以由许多轻量级进程所组成,这些轻量级进程可以运行在公用的地址空间,公用的内存页甚至运行在公用的打开的文件等。Linux定义了它独有的轻量级进程版本,该版本和其他那些运行在SVR4和Solaris上的版本不同。和LWP的所有商用Unix变种基于内核线程不同,Linux将轻量级进程作为基本的运行上下文并通过clone()这个非标准的系统调用来进行处理。
|