Anatomy of the Linux kernel--转
When discussing architecture of a large and complex system,you can view the system from many perspectives. One goal of an architectural decomposition is to provide a way to better understand the source,and that's what we'll do here. The Linux kernel implements a number of important architectural attributes. At a high level,and at lower levels,the kernel is layered into a number of distinct subsystems. Linux can also be considered monolithic because it lumps all of the basic services into the kernel. This differs from a microkernel architecture where the kernel provides basic services such as communication,I/O,and memory and process management,and more specific services are plugged in to the microkernel layer. Each has its own advantages,but I'll steer clear of that debate. Over time,the Linux kernel has become efficient in terms of both memory and CPU usage,as well as extremely stable. But the most interesting aspect of Linux,given its size and complexity,is its portability. Linux can be compiled to run on a huge number of processors and platforms with different architectural constraints and needs. One example is the ability for Linux to run on a process with a memory management unit (MMU),as well as those that provide no MMU. The uClinux port of the Linux kernel provides for non-MMU support. See the??section for more details.
Now let's look at some of the major components of the Linux kernel using the breakdown shown in Figure 3 as a guide. The SCI is a thin layer that provides the means to perform function calls from user space into the kernel. As discussed previously,this interface can be architecture dependent,even within the same processor family. The SCI is actually an interesting function-call multiplexing and demultiplexing service. You can find the SCI implementation in ./linux/kernel,as well as architecture-dependent portions in ./linux/arch. More details for this component are available in the??section. As shown in?,a kernel is really nothing more than a resource manager. Whether the resource being managed is a process,memory,or hardware device,the kernel manages and arbitrates access to the resource between multiple competing users (both in the kernel and in user space). Process management is focused on the execution of processes. In the kernel,these are called?threads?and represent an individual virtualization of the processor (thread code,data,stack,and CPU registers). In user space,the term?process?is typically used,though the Linux implementation does not separate the two concepts (processes and threads). The kernel provides an application program interface (API) through the SCI to create a new process (fork,exec,or Portable Operating System Interface [POSIX] functions),stop a process (kill,exit),and communicate and synchronize between them (signal,or POSIX mechanisms). Also in process management is the need to share the CPU between the active threads. The kernel implements a novel scheduling algorithm that operates in constant time,regardless of the number of threads vying for the CPU. This is called the O(1) scheduler,denoting that the same amount of time is taken to schedule one thread as it is to schedule many. The O(1) scheduler also supports multiple processors (called Symmetric MultiProcessing,or SMP). You can find the process management sources in ./linux/kernel and architecture-dependent sources in ./linux/arch). You can learn more about this algorithm in the??section. Another important resource that's managed by the kernel is memory. For efficiency,given the way that the hardware manages virtual memory,memory is managed in what are called?pages?(4KB in size for most architectures). Linux includes the means to manage the available memory,as well as the hardware mechanisms for physical and virtual mappings. (编辑:应用网_丽江站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |