Linux是嵌入式系统开发中常用的os,本书是为那些想了解Linux内核工作原理的Linux狂热爱好者而写它并非一本内部手册主要描叙了Linux设计的原理与机制以及Linux内核怎样工作及其原因Linux还在不断改进本书基于目前比较流行且性能稳定的2.0.33核心。
目 录
LEGAL NOTICE....................................................................................................................................................5
前言..........................................................................................................................................................................6
本书的组织..........................................................................................................................................................7
第一章硬件基础.....................................................................................................................................................9
1.1 CPU..............................................................................................................................................................10
1.2 内存............................................................................................................................................................. 11
1.3 总线............................................................................................................................................................. 11
1.4 控制器与外设.............................................................................................................................................12
1.5 地址空间.....................................................................................................................................................12
1.6 时钟.............................................................................................................................................................12
第二章软件基础...................................................................................................................................................12
2.1 计算机编程语言.........................................................................................................................................13
2.1.1 汇编语言.............................................................................................................................................13
2.1.2 C 编程语言和编译器............................................................................................................................13
2.1.3 连接程序.............................................................................................................................................14
2.2 操作系统概念.............................................................................................................................................14
2.2.1 内存管理.............................................................................................................................................15
2.2.2 进程.....................................................................................................................................................15
2.2.3 设备驱动.............................................................................................................................................16
2.2.4 文件系统.............................................................................................................................................16
2.3 核心数据结构.............................................................................................................................................16
2.3.1 连接列表.............................................................................................................................................16
2.3.2 散列表.................................................................................................................................................17
2.3.3 抽象接口.............................................................................................................................................17
第三章存储管理...................................................................................................................................................17
3.1 虚拟内存的抽象模型.................................................................................................................................18
3.1.1 请求换页.............................................................................................................................................19
3.1.2 交换.....................................................................................................................................................20
3.1.3 共享虚拟内存...................................................................................................................................20
3.1.4 物理与虚拟寻址模式........................................................................................................................21
3.1.5 访问控制...........................................................................................................................................21
3.2 高速缓冲...................................................................................................................................................22
3.3 LINUX 页表...............................................................................................................................................23
3.4 页面分配与回收.......................................................................................................................................23
3.4.1 页面分配...........................................................................................................................................24
3.4.2 页面回收...........................................................................................................................................25
3.5 内存映射...................................................................................................................................................26
3.6 请求换页...................................................................................................................................................27
3.7 LINUX页面CACHE ....................................................................................................................................28
3.8 换出与丢弃页面.......................................................................................................................................28
3.8.1 减少Page Cache和Buffer Cache的大小.........................................................................................29
3.8.2 换出系统V 内存页面........................................................................................................................30
3.8.3 换出和丢弃页面...............................................................................................................................30
3.9 THE SWAP CACHE.......................................................................................................................................31
3.10 页面的换入.............................................................................................................................................31
第四章进程管理...................................................................................................................................................32
4.1 LINUX进程................................................................................................................................................33
4.2 IDENTIFIERS................................................................................................................................................35
Linux Kernel Page 2
4.3 调度...........................................................................................................................................................35
4.3.1 多处理器系统中的调度....................................................................................................................37
4.4 文件...........................................................................................................................................................38
4.5 虚拟内存...................................................................................................................................................39
4.6 进程创建...................................................................................................................................................40
4.7 时钟和定时器...........................................................................................................................................41
4.8 程序执行...................................................................................................................................................41
4.8.1 ELF....................................................................................................................................................42
4.8.2 脚本文件...........................................................................................................................................44
第五章进程间通讯机制.......................................................................................................................................44
5.1 信号...........................................................................................................................................................44
5.2 管道...........................................................................................................................................................46
5.3 套接口.......................................................................................................................................................48
5.3.1 系统V IPC 机制...............................................................................................................................48
5.3.2 消息队列...........................................................................................................................................48
5.3.3 信号灯...............................................................................................................................................49
5.3.4 共享内存...........................................................................................................................................51
第六章 PCI............................................................................................................................................................52
6.1 PCI 地址空间............................................................................................................................................53
6.2 PCI 配置头...............................................................................................................................................54
6.3 PCI I/O 和PCI 内存地址..........................................................................................................................55
6.4 PCI-ISA 桥接器.......................................................................................................................................56
6.5 PCI-PCI 桥接器.......................................................................................................................................56
6.5.1 PCI-PCI 桥接器PCI I/O 和PCI 内存窗口...................................................................................56
6.5.2 PCI-PCI 桥接器PCI 配置循环及PCI 总线编号方式...................................................................56
6.6 LINUX PCI 初始化过程.............................................................................................................................57
6.6.1 Linux 核心PCI 数据结构.................................................................................................................59
6.6.2 PCI设备驱动....................................................................................................................................60
6.6.3 PCI BIOS 函数.................................................................................................................................63
6.6.4 PCI 补丁代码...................................................................................................................................63
第七章中断及中断处理.......................................................................................................................................65
7.1 可编程中断控制器...................................................................................................................................67
7.2 初始化中断处理数据结构........................................................................................................................67
7.3 中断处理...................................................................................................................................................68
第八章设备驱动...................................................................................................................................................69
8.1 轮询与中断...............................................................................................................................................70
8.2 直接内存访问(DMA)..............................................................................................................................71
8.3 内存...........................................................................................................................................................72
8.4 设备驱动与核心的接口............................................................................................................................72
8.4.1 字符设备...........................................................................................................................................73
8.4.2 块设备...............................................................................................................................................74
8.5 硬盘...........................................................................................................................................................75
8.5.1 IDE 硬盘...........................................................................................................................................76
8.5.2 初始化IDE子系统............................................................................................................................77
8.5.3 SCSI 硬盘.........................................................................................................................................77
8.6 网络设备...................................................................................................................................................80
8.6.1 初始化网络设备...............................................................................................................................82
第九章文件系统...................................................................................................................................................82
9.1 第二代扩展文件系统EXT2 ..............................................................................................................84
9.1.1 The EXT2 Inode ................................................................................................................................85
9.1.2 EXT2 超块.......................................................................................................................................86
9.1.3 EXT2 组标志符................................................................................................................................86
9.1.4 EXT2 目录.......................................................................................................................................87
9.1.5 在EXT2 文件系统中搜寻文件.........................................................................................................88
Linux Kernel Page 3
9.1.6 改变EXT2 文件系统中文件的大小.................................................................................................88
9.2 虚拟文件系统(VFS).................................................................................................................................89
9.2.1 VFS 超块..........................................................................................................................................90
9.2.2 The VFS Inode...................................................................................................................................91
9.2.3 注册文件系统...................................................................................................................................92
9.2.4 安装文件系统...................................................................................................................................92
9.2.5 在虚拟文件系统中搜寻文件.............................................................................................................93
9.2.6 Creating a File in the Virtual File System...........................................................................................94
9.2.7 卸载文件系统...................................................................................................................................94
9.2.8 The VFS Inode Cache.........................................................................................................................94
9.2.9 目录 Cache .......................................................................................................................................95
9.3 THE BUFFER CACHE ...................................................................................................................................96
9.3.1 bdflush 核心后台进程......................................................................................................................97
9.3.2 update进程........................................................................................................................................98
9.4 /PROC文件系统.........................................................................................................................................98
9.5 设备特殊文件...........................................................................................................................................98
第十章网络...........................................................................................................................................................99
10.1 TCP/IP 网络简介....................................................................................................................................99
10.2 LINUX TCP/IP 网络层...........................................................................................................................102
10.3 BSD SOCKET 接口.................................................................................................................................103
10.4 INET SOCKET 层...................................................................................................................................105
10.4.1 建立BSD socket ............................................................................................................................106
10.4.2 将地址与INET BSD socket 绑定..................................................................................................106
10.4.3 在INET BSD Socket 上建立连接.................................................................................................107
10.4.4 监听 INET BSD Socket.................................................................................................................107
10.4.5 接收连接请求...............................................................................................................................108
10.5 IP 层......................................................................................................................................................108
10.5.1 Socket 缓存..................................................................................................................................108
10.5.2 接收IP 包...................................................................................................................................... 110
10.5.3 发送IP 包...................................................................................................................................... 110
10.5.4 数据分块....................................................................................................................................... 111
10.6 地址解析协议(ARP) ............................................................................................................................ 111
10.7 IP 路由................................................................................................................................................. 112
10.7.1 路由缓存....................................................................................................................................... 113
10.7.2 The Forwarding Information Database ........................................................................................... 113
第十一章核心机制............................................................................................................................................. 114
11.1 底层部分处理机制............................................................................................................................... 114
11.2 任务队列............................................................................................................................................... 116
11.3 定时器TIMER ............................................................................................................................... 117
11.4 等待队列............................................................................................................................................... 118
11.5 BUZZ 锁................................................................................................................................................. 118
11.6 信号灯................................................................................................................................................... 118
第十二章模块..................................................................................................................................................... 119
12.1 模块的加载...........................................................................................................................................121
12.2 模块的卸载...........................................................................................................................................122
第十三章处理器.................................................................................................................................................123
13.1 X86........................................................................................................................................................123
13.2 ARM......................................................................................................................................................123
13.3 ALPHA AXP 处理器...............................................................................................................................124
第十四章 LINUX核心资源...............................................................................................................................124
第十五章 LINUX核心数据结构........................................................................................................................128
15.1 BLOCK_DEV_STRUCT........................................................................................................................128
15.2 BUFFER_HEAD.................................................................................................................................128
15.3 DEVICE............................................................................................................................................129
Linux Kernel Page 4
15.4 DEVICE_STRUCT ...............................................................................................................................132
15.5 FILE.................................................................................................................................................132
15.6 FILES_STRUCT .................................................................................................................................132
15.7 FS_STRUCT......................................................................................................................................133
15.8 GENDISK..........................................................................................................................................133
15.9 INODE..............................................................................................................................................134
15.10 IPC_PERM ...................................................................................................................................135
15.11 IRQACTION..................................................................................................................................135
15.12 LINUX_BINFMT ............................................................................................................................136
15.13 MEM_MAP_T...............................................................................................................................136
15.14 MM_STRUCT ...............................................................................................................................137
15.15 PCI_BUS......................................................................................................................................137
15.16 PCI_DEV .....................................................................................................................................137
15.17 REQUEST.....................................................................................................................................138
15.18 RTABLE .......................................................................................................................................139
15.19 SEMAPHORE................................................................................................................................139
15.20 SK_BUFF.....................................................................................................................................140
15.21 SOCK ..........................................................................................................................................141
15.22 SOCKET.......................................................................................................................................145
15.23 TASK_STRUCT.............................................................................................................................146
15.24 TIMER_LIST ................................................................................................................................148
15.25 TQ_STRUCT.................................................................................................................................148
15.26 VM_AREA_STRUCT ......................................................................................................................148
第十六章 LINUX相关WEB 和FTP站点........................................................................................................149
附录A 作者简介.................................................................................................................................................151
附录B THE GNU GENERAL PUBLIC LICENSE..........................................................................................151
Linux Kernel Page 5
下载:
Linux Kernel(中文版).rar