Title: Supplement of Linux Kernel and Process Concept
1Supplement of Linux Kerneland Process Concept
2Lines of Source Code
- Linux 2 million lines
- Microsoft Windows 2000 30 million lines
- Netscape Communicator 5 17 million lines
3Linux 1.2
- Device Drivers 135000(C), 200(Assembly)
- Network 24000(C), 50 Assembly
- VFS layer 9230(C)
- 12 file systems 42000(C)
- Initialization 4000, 1600
- i387 emulation 8600, 3900
- Remainder 12000
4- Linux 1.0 165000 lines of code
- Linux 1.2 270000 C lines of code, 6000 assembly
- Linux 2.4 2 million
5Components in Linux (about OS definition)
SLOC-by-Language ansic2285657,asm144411,sh3035,
perl2022,yacc1147, tcl576,lex302,awk248,sed7
2
SLOC 2437470 2065224 1837608 984076 967263 690983
Directory kernel2.4.2 mozilla XFree86-4.0.3 gcc-2
.96-20000731 gdbdejagnu-20010316 binutils-2.10.91
.0.2
cpp1279902,ansic739470,perl21220,sh13717,asm5
212, java3107,yacc1831,lex470,csh271,sed24
ansic1750460,asm35397,cpp20725,sh14666,tcl918
2, yacc3360,perl1675,lex1608,awk393,csh85,sed
57
ansic789901,cpp126738,yacc19272,sh17993,asm14
559, lisp7161,fortran3814,exp3705,objc479,sed
310,perl144
6SLOC with other systems
7The History
- Initially developed by Linus Torvalds November
1991. - Under GNU Public License
- Alpha, SPARC, Motorola M680x0, PowerPC, and IBM
System/390
8Linux Versions
- A.B.C.D
- A Kernel Version, B Major Revision, C Minor
Revision, D fix for grave errors - 2.2.14 (Version number.release number)
- Version number Even number denotes stable
kernel, odd number with development kernel - Release Number Even number with stable release,
odd number with development release
9Kernel Architecture
- Monolithic kernel versus Microkernel
- Microkernel Explicit message passing between
different layers, slower, but easier to porting
and making better use of RAM - (monolithic) Kernel with loadable modules
- Object file linked to and unlinked from the
kernel at runtime - Runing in kernel mode of current process (instead
of a specific process as in micokernel)
10Advantages of Modules
- Modularized
- Well-defined software interfaces to access the
data structures - Platform independence
- May still dependent on device, but independent of
the hardware platform, such as IBM PC or Compaqs
Alpha - Memory usage load/unload on demand
- No performance penalty equivalent to the object
code of the statically linked kernel
11Reentrant Kernel
- Reentrant function only modify local variable
and do not alter global data structures.
12Logic Concept of CPU
CPU
Process
Virtual Memory
RAM
File
Disk
13Processes
- Programs and Processes
- Execution and address space
- Multiple execution threads in an address space
light-weight process, thread - Switch between user mode and kernel mode by
system call.
14Process Implementation
- Process descriptor
- Program counter, stack pointer
- General-purpose register
- Floating point registers
- Processor control registers
- Memory management registers
15Process Address Space
- Text to be shared by several processes
- Shared memory for IPC
- mmap() to map file or device into part of the
process address space
16Process Management
- fork(), exec(), exit(), abort()
- wait(), and zombie process
- Init
- Process groups and login sessions
17Process Descriptor (task_struct)
- Process State
- TASK_RUNNING
- TASK_INTERRUPIBLE
- TASK_UNINTERRUPTIBLE
- TASK_STOPPED
- SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU
- TASK_ZOMBIE
- wait(), wait3(), wait4(), waitpid()