PART 1:OVERVIEW OF LINUX 1
1.The Evolution of Linux 1
2.General Kernel Responsibilities 4
2.1 Resource Abstraction 5
2.2 Sharing Resources 6
2.2.1 Managing Competition for Resources 6
2.2.2 Exclusive Use of a Resource 7
2.2.3 Managed Sharing 9
2.3 A Partition of OS Functions 9
3.Kernel Organization 10
3.1 Interrupts 12
3.2 Using Kernel Services 14
3.3 Serial Execution 17
3.4 Daemons 18
3.5 The Booting Procedure 19
3.5.1 The Boot Sector 19
3.5.2 Starting the Kernel 21
3.6 Logging In to the Machine 21
3.7 Control Flow in the Machine 22
4.Process and Resource Management 24
4.1 Running the Process Manager 25
4.1.1 System Call 26
4.1.2 Interrupts 26
4.2 Creating a New Task 27
4.3 The Scheduler 29
4.4 IPC and Synchronization 29
4.5 Protection Mechanism 30
5.Memory Management 31
5.1 Managing the Virtual Address Space 32
5.2 The Secondary Memory 33
5.3 Handling Missing Pages 33
5.4 Address Translation 34
6.Device Management 36
6.1 The Device Driver 38
6.2 Handling Interrupts 39
7.File Management 40
7.1 Mounting the File System 42
7.2 Opening a File 44
7.3 Reading and Writing the File 46
7.4 The Ext2 File System 47
8.Learning More about Linux 49
PART 2:EXERCISES 51
1.Observing Linux Behavior 55
Introduction 55
Problem Statement 58
Part A 58
Part D 59
Part B 59
Part C 59
Attacking the Problem 60
The/proc File System 60
Using argc and argv 61
Organizing a Solution 63
Saving Your Work in a Shared Laboratory 65
2.Shell Program 67
Introduction 67
Basic UNIX-Style Shell Operation 69
Putting a Process in the Background 72
I/O Redirection 73
Shell Pipes 74
Reading Multiple Input Streams 77
Problem Statement 77
Part A 77
Part B 78
Part C 78
Attacking the Problem 79
Organizing a Solution 79
Part A 79
Parts B and C 82
Introduction 83
3.Kernel Timers 83
How the Kernel Maintains the Time 84
Per Process Timers 85
Problem Statement 88
Part A 88
Part B 88
Part C 89
Attacking the Problem 89
Organization of the Linux Source Code 89
Signals 90
Organizing a Solution 93
Introduction 97
4.Kernel Modules 97
Module Organization 98
Module Installation and Removal 102
Problem Statement 103
Attacking the Problem 104
The read() Procedure 104
The End-of-File Condition 104
Compiling a Module 105
Installing and Removing a Module 105
The Clock Resolution Question 105
More Help 105
Introduction 107
5.System Calls 107
The System Call Linkage 108
Defining the System Call Number 109
Generating a System Call Stub 111
Kernel Function Organization 111
Referencing User-Space Memory Locations 113
Problem Statement 114
Port A 114
Part B 114
Attacking the Problem 114
The Kernel printk() Function 114
Organizing a Solution 115
Rebuilding the Kernel 116
Leaving a Clean Environment 118
6.Shared Memory 119
Introduction 119
The Shared Memory API 120
The Implementation 124
Problem Statement 130
Attacking the Problem 131
7.Virtual Memory 133
Introduction 133
The Virtual Address Space 135
Virtual Memory Areas 137
Address Translation 139
The Page FaultHandler 140
Primary Memory Allocation 143
Problem Statement 143
Part A:Instrument the Virtual Memory Manager 143
Part B:Reporting the Performance 144
Attackingthe Problem 144
Introduction 145
Blocking a Task 145
8.Synchronization Mechanisms 145
Wait Queues 147
Using Wait Queues 148
Problem Statement 152
Part A 152
Part B 152
Attacking the Problem 152
9.The Scheduler 155
Introduction 155
Process Management 155
Process States 159
Scheduler Implementation 160
Problem Statement 164
Fair-Share Scheduling 164
Part A 165
Part B 165
Attacking the Problem 165
Planning a Solution 165
Comparing Scheduler Performance 165
10.Device Drivers 167
Introduction 167
Driver Organization 169
Loadable Kernel Module Drivers 172
Example:A Disk Driver 173
Part B 176
Problem Statement 176
Part A 176
Attacking the Problem 177
11.File Systems 179
Introduction 179
The Virtual File System 182
Directories 186
Example:An MS-DOS File System 188
Problem Statement 190
Part A 190
Part B 190
The MS-DOS Disk Format 191
Part C 191
Attacking the Problem 191
The MS-DOS FAT 193
Using the Floppy Disk API 198
Planning a Solution 200
12.File I/O 205
Introduction 205
The Open and Close Operations 206
Read and Write Operations 208
Block Allocation 210
Buffer Management 210
Problem Statement 212
Part A 213
Part B 213
Part C 214
Part D 214
Attacking the Problem 214
The open() Function 214
Caching the FAT 215
A Solution Plan 216
Further Study 219
References 221
Index 223