4 Process Control Block
4 Process Control Block
Every process has an address space in user mode and PCB in kernel mode as shown below. User mode address space consists of code segment, data segment, heap and stack.
Stack
Heap
Data segment
Code segment
PCB
PCB is a kernel structure whose instance is created for each process to store process information. PCB is created when the process is loaded and de-allocated when the application is fully terminated Linux kernel uses a structure called task_struct to implement process control block (PCB). This structure can be found in the Linux source code $vim include/linux/sched.h
Important elements of PCB: task_struct contains following Process identification information (PID ,PPID ,CPID ) Process scheduling policy and state Information about number of user level threads mapped to the process. mm_struct gives process address space information tty_struct gives the active terminal information
This is only a supplementary material to classroom sessions
files_struct gives the information about the files which the application currently using. It is called file descriptor table. signal _struct gives the signal information.
Users can see PCB through /proc directory. In order to understand more lets run a simple C file and execute the output. We use a getcar() to put it in a wait state.
Ps -Af is the command used to see the current running process in the kernel. It also shows the PID of the processes. It gives the PID of our program test1
In PID directory we can see a file maps, if we execute $cat maps, which shows mm_struct i.e. it shows the addresses for the particular process as shown below. It also shows the addresses of libraries linked to it.
Thus /proc is a directory which shows the process table and addresses mapped to a particular process.