Linux Process and Thread Management

A process in LINUX is a single program running in its own virtual space on the operating system. To create a process in LINUX, the ‘parent process‘ initiate a fork().
Fork() suggests that the process creates a copy of itself. A process in LINUX is represented by a data structure (like PCB) called ‘task-struct‘. It contains the all information about the process.

LINUX Task Structure:

1. PID: It is a unique process identification number.
2. State: It specifies one of the 5 states of a process.
3. Scheduling Information: It specifies that which type of information needed.
4. Links: Process having the link to its parent process if it is a child process. If it is a parent process links to all of its children.
5. File System: It includes pointers to any files opened by this process.
6. Virtual Memory: It defines the virtual memory assigned to this process.
7. Times and Timers: It specifies process creation time, CPU burst time of a process, etc.
8. Processor-specific context: The registers and stack information that constitute the context of this process.

Process / Thread States in LINUX:

Process States in LINUX

1. Running: It includes two states:
    i. Ready
    ii. Executing
2. Interruptible: It is a suspended state when the process or thread is waiting for an event, and then it enters into an interruptible state.
3. Uninterruptible: It is another suspended state, here the process or thread is waiting directly on Hardware conditions.
4. Stopped: The process or thread has been halted and it can only resume by a positive action from another process or thread.
5. Zombie: It terminates when the execution completes.