《深入理解Linux内核》读书笔记 第一章 绪论(1)

一、Linux与其它类Unix内核的比较:


单块结构的内核:由几个逻辑上独立的成分构成,单块结构,大多数据商用Unix变体也是单块结构;


编译并静态连接的传统Unix内核:Linux能自动按需动态地装载和卸载部分内核代码(模块),而传统Unix内核仅支持静态连接;


内核线程:Linux以一种十分有限的方式使用内核线程来周期性地执行几个内核函数,而一些Unix内核则本身被组织成一组内核线程;


多线程应用程序支持:Linux定义了自己的轻量级进程版本,并以此来实现对多线程应用程序的支持,而商用Unix则都是基于内核线程来作为多线程应用程序的执行环境;


抢占式内核:Linux2.6提供了“可抢占的内核”的编译选项,当采用这种编译方式来编译内核时,Linux2.6可以随意交错执行处于特权模式的执行流,而一些传统的、通用的Unix,如Solaris则是完全的抢占式内核;


多处理器支持:一些Unix内核变体都利用了多处理器系统,Linux2.6支持不同存储模式的对称多处理,不仅可以使用多处理器,同时每个处理器可以毫无区别地处理任何一个任务;

注:"对称多处理"Symmetrical Multi-Processing)又叫SMP,是指在一个计算机上汇集了一组处理器(CPU),CPU之间共享内存子系统以及总线结构。


文件系统:Linux标准文件系统支持多种不同类型的文件系统,由于采用了面向对象虚拟文件系统技术,外部文件系统可以很容易移植到Linux内核上;

注:虚拟文件系统(VFS)是物理文件系统与服务之间的一个接口层,它对Linux的每个文件系统的所有细节进行抽象,使得不同的文件系统在Linux核心以 及系统中运行的其他进程看来,都是相同的。严格说来,VFS并不是一种实际的文件系统。它只存在于内存中,不存在于任何外存空间。VFS在系统启动时建 立,在系统关闭时消亡


STREAMS:大部分Unix内核均包含STREAMS I/O子系统,作为编写设备驱动程序、终端驱动程序及网络协议的首选接口,但Linux无类似的子系统;



二、硬件依赖性:



Linux试图在硬件无关的源代码与硬件相关的源代码之间保持清晰的界限,为此,Linux为不同的硬件平台作了不同的支持,目前共对23种不同的硬件平台类型作了专门的支持。



三、操作系统基本概念:



当操作系统启动时,内核被装入到RAM中,内核中包含了系统运行所必须的很多核心过程。内核为系统中所有事情提供了主要功能,并决定高层软件的许多特性。


操作系统的两个主要目标:与硬件交互以及为运行在其上的应用程序提供执行环境。


多用户系统:


能并发和独立执行分别属于两个或多个用户的若干应用程序的计算机。

“并发”意味着几个应用程序能同时处于活动状态并竞争各种资源;

“独立”意味着每个应用程序能执行自己的任务,而无需考虑其他用户的应用程序在干些什么;

多用户操作系统必须包含的特点:

l 核实用户身份的认证机制;

l 防止有错误的应用程序妨碍到其它应用程序在系统中运行的保护机制;

l 防止有恶意用户程序干涉或窥视其它用户的活动的保护机制;

l 限制分配给每个用户的资源数的记账机制;

以上保护机制依赖与CPU特权模式相关的硬件保护机制。


用户和组:


所有的用户由一个唯一的用户标识符来标识。

为了实现资料的共享,引入用户组,组由唯一的用户组标识符来标识。

任何类Unix操作系统都有一个特殊的root用户,即超级用户,操作系统不对她使用通常的保护机制,可以访问系统中的任何一个文件,并干涉任何一个正在执行的用户程序活动。


进程:


程序执行的一个实例,一个运行程序的“执行上下文”。

Unix是具有抢占式进程的多处理器操作系统。

Unix操作系统采用进程/内核模式,每个进程都自以为它是系统中唯一的进程,可以独占操作系统所提供的服务。只要进程发出系统调用,硬件就会把特权模式由用户态变成内核态,然后进程以非常有限的目的开始一个内核过程的执行。

内核体系结构:

大部分Unix内核是单块结构:每一个内核层都被集成到整个内核程序中,并代表当前进程在内核态下运行。


微内核操作系统只需要内核有一个很小的函数集,通常包括几个同步原语、一个简单的调度程序和进程间的通信机制。


微内核操作系统一般比单块内核的效率低,因此操作系统不同层次之间显式的消息传递要花费一定的代价。


微内核操作系统迫使系统程序员采用模块化方法,因为任何操作系统层都是一个相对独立的程序,这种程序必须通过定义明确而清晰的软件接口,以实现与其他层的交互,同时时方便移植。


微内核操作系统比单块内核更充分的利用了RAM


Linux内核提供了模块。模块是一个目标文件,其代码可以在运行时链接到内核,或从内核上解除链接。这种目标代码通常由一组函数组成,用来实现文件系统、驱动程序或其它内核上层功能。


四、Unix文件系统概述:


文件:


Unix文件是以字节序列组成的信息载体,内核不解释文件的内容。


文件或目录名由除了“/”和“\0”之外的任意ASCII字符序列组成,通常不能超过255个字符。


当标识文件名时,“.”和“..”分别用来标识当前工作目录和父目录。


硬链接和软链接:


包含在目录中的文件名就是一个文件的硬链接,或简称链接。


软链接又称为符号链接,是短文件,这些文件包含有另一个文件的任意一个路径名。


文件类型:


Unix文件可以是下列类型之一:

l 普通文件

l 目录

l 符号链接

l 面向块的设备文件

l 面向字符的设备文件

l 管道和命令管道

l 套接字(Socket)


文件描述符与索引节点:


文件内容不包含任何控制信息。

文件系统处理文件需要的所有信息包含在一个名为索引节点的数据结构中。

索引节点至少提供以下属性:

l 文件类型

l 与文件相关的硬链接个数

l 以字节为单位的文件长度

l 设备标识符(包含文件的设备的标识符)

l 在文件系统中识别文件的索引节点号

l 文件拥有者的UID

l 文件的用户组ID

l 几个时间戳,表示索引节点状态改变的时间、最后访问时间及最后修改时间

l 访问权限和文件模式

l



文件操作的系统调用:


当用户访问一个变通文件或目录文件的内容时,实际是访问硬件设备上的一些数据,因此,文件系统是硬盘分区物理组织的用户级视图。而由于处于用户态的进程不能直接与低层硬件交互,因此,所有实际的文件操作都必须在内核态下进行。

当几个进程同时打开一个文件时,文件系统给每个文件分配一个单独的打开文件对象以及单独的文件描述符。在这种情况下,Unix文件系统对进程在同一文件上发出的I/O操作之间不提供任何形式的同步机制。

对普通Unix文件,可以顺序访问,也可随机访问,而对设备文件和命名管道文件,通常只能顺序访问。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Preface The Audience for This Book Organization of the Material Level of Description Overview of the Book Background Information Conventions in This Book How to Contact Us Safari? Enabled Acknowledgments Chapter 1. Introduction Section 1.1. Linux Versus Other Unix-Like Kernels Section 1.2. Hardware Dependency Section 1.3. Linux Versions Section 1.4. Basic Operating System Concepts Section 1.5. An Overview of the Unix Filesystem Section 1.6. An Overview of Unix Kernels Chapter 2. Memory Addressing Section 2.1. Memory Addresses Section 2.2. Segmentation in Hardware Section 2.3. Segmentation in Linux Section 2.4. Paging in Hardware Section 2.5. Paging in Linux Chapter 3. Processes Section 3.1. Processes, Lightweight Processes, and Threads Section 3.2. Process Descriptor Section 3.3. Process Switch Section 3.4. Creating Processes Section 3.5. Destroying Processes Chapter 4. Interrupts and Exceptions Section 4.1. The Role of Interrupt Signals Section 4.2. Interrupts and Exceptions Section 4.3. Nested Execution of Exception and Interrupt Handlers Section 4.4. Initializing the Interrupt Descriptor Table Section 4.5. Exception Handling Section 4.6. Interrupt Handling Section 4.7. Softirqs and Tasklets Section 4.8. Work Queues Section 4.9. Returning from Interrupts and Exceptions Chapter 5. Kernel Synchronization Section 5.1. How the Kernel Services Requests Section 5.2. Synchronization Primitives Section 5.3. Synchronizing Accesses to Kernel Data Structures Section 5.4. Examples of Race Condition Prevention Chapter 6. Timing Measurements Section 6.1. Clock and Timer Circuits Section 6.2. The Linux Timekeeping Architecture Section 6.3. Updating the Time and Date Section 6.4. Updating System Statistics Section 6.5. Software Timers and Delay Functions Section 6.6. System Calls Related to Timing Measurements Chapter 7. Process Scheduling Section 7.1. Scheduling Policy Section 7.2. The Scheduling Algorithm Section 7.3. Data Structures Used by the Scheduler Section 7.4. Functions Used by the Scheduler Section 7.5. Runqueue Balancing in Multiprocessor Systems Section 7.6. System Calls Related to Scheduling Chapter 8. Memory Management Section 8.1. Page Frame Management Section 8.2. Memory Area Management Section 8.3. Noncontiguous Memory Area Management Chapter 9. Process Address Space Section 9.1. The Processs Address Space Section 9.2. The Memory Descriptor Section 9.3. Memory Regions Section 9.4. Page Fault Exception Handler Section 9.5. Creating and Deleting a Process Address Space Section 9.6. Managing the Heap Chapter 10. System Calls Section 10.1. POSIX APIs and System Calls Section 10.2. System Call Handler and Service Routines Section 10.3. Entering and Exiting a System Call Section 10.4. Parameter Passing Section 10.5. Kernel Wrapper Routines Chapter 11. Signals Section 11.1. The Role of Signals Section 11.2. Generating a Signal Section 11.3. Delivering a Signal Section 11.4. System Calls Related to Signal Handling Chapter 12. The Virtual Filesystem Section 12.1. The Role of the Virtual Filesystem (VFS) Section 12.2. VFS Data Structures Section 12.3. Filesystem Types Section 12.4. Filesystem Handling Section 12.5. Pathname Lookup Section 12.6. Implementations of VFS System Calls Section 12.7. File Locking Chapter 13. I/O Architecture and Device Drivers Section 13.1. I/O Architecture Section 13.2. The Device Driver Model Section 13.3. Device Files Section 13.4. Device Drivers Section 13.5. Character Device Drivers Chapter 14. Block Device Drivers Section 14.1. Block Devices Handling Section 14.2. The Generic Block Layer Section 14.3. The I/O Scheduler Section 14.4. Block Device Drivers Section 14.5. Opening a Block Device File Chapter 15. The Page Cache Section 15.1. The Page Cache Section 15.2. Storing Blocks in the Page Cache Section 15.3. Writing Dirty Pages to Disk Section 15.4. The sync( ), fsync( ), and fdatasync( ) System Calls Chapter 16. Accessing Files Section 16.1. Reading and Writing a File Section 16.2. Memory Mapping Section 16.3. Direct I/O Transfers Section 16.4. Asynchronous I/O Chapter 17. Page Frame Reclaiming Section 17.1. The Page Frame Reclaiming Algorithm Section 17.2. Reverse Mapping Section 17.3. Implementing the PFRA Section 17.4. Swapping Chapter 18. The Ext2 and Ext3 Filesystems Section 18.1. General Characteristics of Ext2 Section 18.2. Ext2 Disk Data Structures Section 18.3. Ext2 Memory Data Structures Section 18.4. Creating the Ext2 Filesystem Section 18.5. Ext2 Methods Section 18.6. Managing Ext2 Disk Space Section 18.7. The Ext3 Filesystem Chapter 19. Process Communication Section 19.1. Pipes Section 19.2. FIFOs Section 19.3. System V IPC Section 19.4. POSIX Message Queues Chapter 20. Program ExZecution Section 20.1. Executable Files Section 20.2. Executable Formats Section 20.3. Execution Domains Section 20.4. The exec Functions Appendix A. System Startup Section A.1. Prehistoric Age: the BIOS Section A.2. Ancient Age: the Boot Loader Section A.3. Middle Ages: the setup( ) Function Section A.4. Renaissance: the startup_32( ) Functions Section A.5. Modern Age: the start_kernel( ) Function Appendix B. Modules Section B.1. To Be (a Module) or Not to Be? Section B.2. Module Implementation Section B.3. Linking and Unlinking Modules Section B.4. Linking Modules on Demand Bibliography Books on Unix Kernels Books on the Linux Kernel Books on PC Architecture and Technical Manuals on Intel Microprocessors Other Online Documentation Sources Research Papers Related to Linux Development About the Authors Colophon Index

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值