已阅读5页,还剩10页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
荆楚理工学院 学生课程考核论文 荆楚理工学院 学生课程考核论文 学 院 计算机工程学院 学 院 计算机工程学院 专 业 计算机科学与技术 专 业 计算机科学与技术 班 级 10 级计算机科学与技术一班 班 级 10 级计算机科学与技术一班 课 程 计算机专业英语 课 程 计算机专业英语 论文题目 Anatomy of the Linux kernel 论文题目 Anatomy of the Linux kernel 学生姓名 樊聪 学生姓名 樊聪 时 间 2013 年 1 月 1 日 时 间 2013 年 1 月 1 日 成绩评定 成绩评定 荆楚理工学院 荆楚理工学院 10 计算机本一 出处 出处 原文 原文 Anatomy of the Linux kernel Kernel architectural decomposition The Linux kernel is the core of a large and complex operating system and while it s huge it is well organized in terms of subsystems and layers In this article you explore the general structure of the Linux kernel and get to know its major subsystems and core interfaces Where possible you get links to other IBM articles to help you Given that the goal of this article is to introduce you to the Linux kernel and explore its architecture and major components let s start with a short tour of Linux kernel history then look at the Linux kernel architecture from 30 000 feet and finally examine its major subsystems The Linux kernel is over six million lines of code so this introduction is not exhaustive Use the pointers to more content to dig in further A short tour of Linux history Linux or GNU Linux You ve probably noticed that Linux as an operating system is referred to in some cases as Linux and in others as GNU Linux The reason behind this is that Linux is the kernel of an operating system The wide range of applications that make the operating system useful are the GNU software For example the windowing system compiler variety of shells development tools editors utilities and other applications exist outside of the kernel many of which are GNU software For this reason many consider GNU Linux a more appropriate name for the operating system while Linux is appropriate when referring to just the kernel While Linux is arguably the most popular open source operating system its history is actually quite short considering the timeline of operating systems In the early days of computing programmers developed on the bare hardware in the hardware s language The lack of an operating system meant that only one application and one user could use the large and expensive device at a time Early operating systems were developed in the 1950s to provide a simpler development experience Examples include the General Motors Operating System GMOS developed for the IBM 701 and the FORTRAN Monitor System FMS developed by North American Aviation for the IBM 709 荆楚理工学院 文五 505 樊聪 2 荆楚理工学院 荆楚理工学院 10 计算机本一 In the 1960s Massachusetts Institute of Technology MIT and a host of companies developed an experimental operating system called Multics or Multiplexed Information and Computing Service for the GE 645 One of the developers of this operating system AT T dropped out of Multics and developed their own operating system in 1970 called Unics Along with this operating system was the C language for which C was developed and then rewritten to make operating system development portable Twenty years later Andrew Tanenbaum created a microkernel version of UNIX called MINIX for minimal UNIX that ran on small personal computers This open source operating system inspired Linus Torvalds initial development of Linux in the early 1990s see Figure 1 Figure 1 Short history of major Linux kernel releases Linux quickly evolved from a single person project to a world wide development project involving thousands of developers One of the most important decisions for Linux was its adoption of the GNU General Public License GPL Under the GPL the Linux kernel was protected from commercial exploitation and it also benefited from the user space development of the GNU project of Richard Stallman whose source dwarfs that of the Linux kernel This allowed useful applications such as the GNU Compiler Collection GCC and various shell support Introduction to the Linux kernel Now on to a high altitude look at the GNU Linux operating system architecture You can think about an operating system from two levels as shown in Figure 2 Figure 2 The fundamental architecture of the GNU Linux operating system 荆楚理工学院 文五 505 樊聪 3 荆楚理工学院 荆楚理工学院 10 计算机本一 Methods for system call interface SCI In reality the architecture is not as clean as what is shown in Figure 2 For example the mechanism by which system calls are handled transitioning from the user space to the kernel space can differ by architecture Newer x86 central processing units CPUs that provide support for virtualization instructions are more efficient in this process than older x86 processors that use the traditional int 80h method At the top is the user or application space This is where the user applications are executed Below the user space is the kernel space Here the Linux kernel exists There is also the GNU C Library glibc This provides the system call interface that connects to the kernel and provides the mechanism to transition between the user space application and the kernel This is important because the kernel and user application occupy different protected address spaces And while each user space process occupies its own virtual address space the kernel occupies a single address space For more information see the links in the Resources section The Linux kernel can be further divided into three gross levels At the top is the system call interface which implements the basic functions such as read and write Below the system call interface is the kernel code which can be more accurately defined as the architecture independent kernel code This code is common to all of the processor architectures supported by Linux Below this is the architecture dependent code which forms what is more commonly called a BSP Board Support Package This code serves as the processor and platform specific code for the given architecture 荆楚理工学院 文五 505 樊聪 4 荆楚理工学院 荆楚理工学院 10 计算机本一 Properties 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 Resources section for more details Major subsystems of the Linux kernel Now let s look at some of the major components of the Linux kernel using the breakdown shown in Figure 3 as a guide Figure 3 One architectural perspective of the Linux kernel System call interface 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 荆楚理工学院 文五 505 樊聪 5 荆楚理工学院 荆楚理工学院 10 计算机本一 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 Resources section Process management What is a kernel As shown in Figure 3 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 Resources section Memory management 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 But memory management is much more than managing 4KB buffers Linux provides abstractions over 4KB buffers such as the slab allocator This memory 荆楚理工学院 文五 505 樊聪 6 荆楚理工学院 荆楚理工学院 10 计算机本一 management scheme uses 4KB buffers as its base but then allocates structures from within keeping track of which pages are full partially used and empty This allows the scheme to dynamically grow and shrink based on the needs of the greater system Supporting multiple users of memory there are times when the available memory can be exhausted For this reason pages can be moved out of memory and onto the disk This process is called swapping because the pages are swapped from memory onto the hard disk You can find the memory management sources in linux mm Virtual file system The virtual file system VFS is an interesting aspect of the Linux kernel because it provides a common interface abstraction for file systems The VFS provides a switching layer between the SCI and the file systems supported by the kernel see Figure 4 Figure 4 The VFS provides a switching fabric between users and file systems At the top of the VFS is a common API abstraction of functions such as open close read and write At the bottom of the VFS are the file system abstractions that define how the upper layer functions are implemented These are plug ins for the given file system of which over 50 exist You can find the file system sources in linux fs Below the file system layer is the buffer cache which provides a common set of functions to the file system layer independent of any particular file system This caching layer optimizes access to the physical devices by keeping data around for a short time or speculatively read ahead so that the data is available when needed Below the buffer cache are the device drivers which implement the interface for the particular physical device 荆楚理工学院 文五 505 樊聪 7 荆楚理工学院 荆楚理工学院 10 计算机本一 Network stack The network stack by design follows a layered architecture modeled after the protocols themselves Recall that the Internet Protocol IP is the core network layer protocol that sits below the transport protocol most commonly the Transmission Control Protocol or TCP Above TCP is the sockets layer which is invoked through the SCI The sockets layer is the standard API to the networking subsystem and provides a user interface to a variety of networking protocols From raw frame access to IP protocol data units PDUs and up to TCP and the User Datagram Protocol UDP the sockets layer provides a standardized way to manage connections and move data between endpoints You can find the networking sources in the kernel at linux net Device drivers The vast majority of the source code in the Linux kernel exists in device drivers that make a particular hardware device usable The Linux source tree provides a drivers subdirectory that is further divided by the various devices that are supported such as Bluetooth I2C serial and so on You can find the device driver sources in linux drivers Architecture dependent code While much of Linux is independent of the architecture on which it runs there are elements that must consider the architecture for normal operation and for efficiency The linux arch subdirectory defines the architecture dependent portion of the kernel source contained in a number of subdirectories that are specific to the architecture collectively forming the BSP For a typical desktop the i386 directory is used Each architecture subdirectory contains a number of other subdirectories that focus on a particular aspect of the kernel such as boot kernel memory management and others You can find the architecture dependent code in linux arch Interesting features of the Linux kernel If the portability and efficiency of the Linux kernel weren t enough it provides some other features that could not be classified in the previous decomposition Linux being a production operating system and open source is a great test bed for new protocols and advancements of those protocols Linux supports a large number of networking protocols including the typical TCP IP and also extension for high speed networking greater than 1 Gigabit Ethernet GbE and 荆楚理工学院 文五 505 樊聪 8 荆楚理工学院 荆楚理工学院 10 计算机本一 10 GbE Linux also supports protocols such as the Stream Control Transmission Protocol SCTP which provides many advanced features above TCP as a replacement transport level protocol Linux is also a dynamic kernel supporting the addition and removal of software components on the fly These are called dynamically loadable kernel modules and they can be inserted at boot when they re needed when a particular device is found requiring the module or at any time by the user A recent advancement of Linux is its use as an operating system for other operating systems called a hypervisor Recently a modification to the kernel was made called the Kernel based Virtual Machine KVM This modification enabled a new interface to user space that allows other operating systems to run above the KVM enabled kernel In addition to running another instance of Linux Microsoft Windows can also be virtualized The only constraint is that the underlying processor must support the new virtualization instructions See the Resources section for more information Going further This article just scratched the surface of the Linux kernel architecture and its features and capabilities You can check out the Documentation directory that s provided in every Linux distribution for detailed information about the contents of the kernel Be sure to check out the Resources section at the end of this article for more detailed information about many of the topics discussed here 荆楚理工学院 文五 505 樊聪 9 荆楚理工学院 荆楚理工学院 10 计算机本一 译文 译文 Linux 内核剖析内核剖析 内核体系结构分解 Linux 内核是一个大型的 复杂的操作系统核心 尽管它庞大 但它的子系统 和层次都组织得很好 本文将探究 Linux 内核的通用结构 并了解它的主要子系统 和核心接口 如果可能 你可以链接其它 IBM 文章获得帮助 因为本文目的是介绍 Linux 内核 并探索它的体系结构和主要部件 让我们先 回顾一下 Linux 内核的简短历史 之后从较高的角度看一下 Linux 内核结构 最后 介绍它的主要子系统 Linux 内核具有超过 6 百万行代码 因此 本文不可能详尽 地介绍它 请使用其它链接来进一步学习更多的内容 Linux简短历史简短历史 尽管 Linux 被认证为最流行的开放源码的操作系统 但是 相对于别的操作系 统的漫长历史 它的历史实际上相当短暂 在计算机出现早期 程序员使用硬件 语言在裸机上开发 缺乏操作系统意味着在每次只有一个应用程序 和一个用户 可以使用这些庞大而昂贵的设备 早期的操作系统于 20 世纪 50 年代开发 提供 一个简单的开发体验 这些例子包括为 IBM 701 开发的 General Motors Operating System GMOS 通用汽车操作系统 以及北美航空为 IBM 709 开发的 FORTRAN Monitor System FMS FORTRAN 监控系统 19 世纪 60 年代 麻省理工学院 MIT 和许多公司为 GE 645 开发了一个实验用 的操作系统 叫 Multics Multiplexed Information and Computing Service 该操作系 统的开发者之一 AT T 退出了 Multics 并在 1970 年开发了他们自己的操作系 统 即 Unics 与此操作系统一起诞生的是 C 语言 C 语言就是为此而开发的 后 来他们使用 C 语言对操作系统进行了重写 使得操作系统的开发具有可移植性 20 年后 Andrew Tanenbaum 创建一个 UNIX 的微内核版本 名为 MINIX 意 为微型 UNIX 它可以运行在小型个人计算机上 这个开放源代码的操作系统激 发了 Linus Torvalds 在 20 世纪 90 年代开发 Linux 的灵感 见图 1 图图 1 主要 主要 Linux 内核发布的简短历史内核发布的简短历史 荆楚理工学院 文五 505 樊聪 10 荆楚理工学院 荆楚理工学院 10 计算机本一 Linux 很快就由一个个人项目进化为一个全世界数千开发者参与的项目 最重 要的决策之一就是 Linux 采用了 GNU 通用公共协议 GPL 在 GPL 条款保护下 Linux 内核可以防止在商业上使用 它也利益于 GNU 项目 由 Richard Stallman 开 发 它的源码比 Linux 内核大得多 的用户空间开发 这允许一些有用的应用程序 如 GUN 编译器集合 GCC 和各种 shell 支持 Linux 内核介绍内核介绍 现在从一个较高的视角来看一下 GNU Linux 操作系统的体系结构 你可以从 两个层次考虑操作系统 如图 2 所示 图图 2 GNU Linux 操作系统基本体系结构操作系统基本体系结构 顶层是用户 或者应用程序 空间 用户应用程序就在这里执行 在用户空间之 下就是内核空间 Linux 内核即在此处存在 GNU C 库 glibc 也在这里 指用户空间 见图 它提供系统调用接口来连接到 荆楚理工学院 文五 505 樊聪 11 荆楚理工学院 荆楚理工学院 10 计算机本一 内核 并提供用户空间应用程序与内核的转换机制 这一点很重要 因为内核与 用户应用程序占用不同的保护地址空间 每一个用户空间进程占用它自己私有地 址空间 而内核只占用一个单独的地址空间 更多信息 参考资源列表的链接 Linux 内核可以进一步划分成大约三层 最顶层为系统调用接口 它实现基本 的功能如 read 和 write 在系统调用接口之下的是内核代码 更准确的定义是与独 立于体系结构的内核代码 这些代码是 Linux 所支持的自有处理器体系结构所共有 的 在这之下 是依赖体系结构的代码 形成了通常所说的 BSP Board Suport Package 板级支持包 这些代码用于给定的体系结构的处理器和平台相关代码 Linux内核的属性内核的属性 当讨论一个庞大而复杂的系统体系结构时 你可以从不同的角度来审视这个 系统 分解某个体系结构的一个目的 就是提供一种途径以更好地理解源代码 这正是写本文的原因 Linux 内核实现了许多重要的体系结构属性 无论从高的还是低的层次来看 内核可以分为许多独特的子系统 Linux 也可以看成是一个整体 因为它将所有基 本的服务都整合到内核中 这与微内核结构不同 微内核会提供基本服务 如通 信 I O 内存和进程管理 此外 更多的具体的服务正添加到微内核中层 每个 内核都有自己的优点 但这里绕开这些辩论 随着时间的流逝 Linux 内核已经在内存和 CPU 使用上变得更加有效 同时 也更加稳定 但 Linux 最有趣的方面 考虑到它的大小与复杂性 是它的可移 植性 Linux 可以编译后运行于大量的处理器与不同体系结构的平台 一个例子就 是 Linux 可以运行在有内存管理单元 MMU 的处理器上 也可以运行在那些没有 MMU 的处理器上 Linux 内核的 uClinux 移植提供了对无 MMU 的支持 更多详 细的信息 参考资源列表 Linux内核的主要子系统内核的主要子系统 现在 让我们看一下 Linux 内核的一些主要组成部件 这些分类如图 3 所示 图图 3 Linux 内核的一个架构透视图内核的一个架构透视图 荆楚理工学院 文五 505 樊聪 12 荆楚理工学院 荆楚理工学院 10 计算机本一 系统调用接口系统调用接口 SCI SCI 是一
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 餐饮茶室设计案例分析
- 航空业空乘服务态度与技能考核表
- 2026届湖北省鄂州市鄂州高中化学高二上期末监测模拟试题含答案
- 科技公司研发团队项目完成度与创新能力考核表
- 人力资源管理流程优化方案框架
- 网络安全领域安全分析师绩效评定表
- 企业文档快速审批模板库
- 客户关系管理客户关系划分及跟进流程
- 企业会议管理流程包括会议通知及纪要跟进模板
- 七夕情缘汽车盛宴
- 中药学类专业大学生职业生涯规划书
- 茂名市恒兴养殖有限公司江湖镇龙梅生产基地建设项目环评报告
- 起重机维护保养记录表
- 2023年07月广西自然资源职业技术学院招考聘用笔试历年难易错点考题荟萃附带答案详解
- 2019电网通信网络运行班组标准化管理手册
- 年产1000吨山野菜加工生产线项目谋划书
- (课本版)《报任安书》
- 自动喷漆线使用说明书
- 西安某综合办公楼弱电智能化设计方案
- 西南交通大学机械原理课后习题答案
- GB/T 27551-2011金属材料焊缝破坏性试验断裂试验
评论
0/150
提交评论