Kernel
Kernel
Topics
Kernel Architecture File System Process
User level
kernel level
character
block
User level
File System
A file system is consists of a sequence of logical blocks (512/1024 byte etc.) A file system has the following structure:
Boot Block
Super Block
Inode List
Data Blocks
Processes(1)
A process is the execution of a program A process is consists of text (machine code), data and stack Many process can run simultaneously as kernel schedules them for execution Several processes may be instances of one program A process reads and writes its data and stack sections, but it cannot read or write the data and stack of other processes A process communicates with other processes and the rest of the world via system calls
Processes(2)
Kernel has a process table that keeps tract of all active processes Each entry in the process table contains pointers to the text, data, stack and the U Area of a process. All processes in UNIX system, except the very first process (process 0) which is created by the system boot code, are created by the fork system call
A Process
Data Stack
U Area
Process: U Area
U Area is the extension of process table entry. Fields of process table entry:
State field User ID (UID)
Fields of U Area
Pointer to process table entry File descriptors of all open files Current directory and current root I/O parameters Process and file size limit
Kernel can directly access fields of the U Area of the executing process but not of the U Area of other processes
Process Context
The context of a process is its state:
Text, data( variable), register Process region table, U Area, User stack and kernel stack
When executing a process, the system is said to be executing in the context of the process.
Context Switch
When the kernel decides that it should execute another process, it does a context switch, so that the system executes in the context of the other process When doing a context switch, the kernel saves enough information so that it can later switch back to the first process and resume its execution.
Kernel mode
Can access kernel and user instructions and data
When a process executes a system call, the execution mode of the process changes from user mode to kernel mode
Process States
Process states are:
The process is running in user mode The process is running in kernel mode The process is not executing, but it is ready to run as soon as the scheduler chooses it The process is sleeping
Such as waiting for I/O to complete
1
return Interrupt return
kernel running
2
schedule process
sleep
asleep
4
context switch permissible
wakeup
ready to run
data
Parent U Area
text
Child U Area
stack data
Region table