- A process is an instance of a program in execution
- A process is the basic unit of execution in an operating system. Each process has a process identifier associated with it. Known as the process_id.
The process state diagram for UNIX system is given below:
- UNIX uses two categories of processes: System processes and user processes.
- System processes operate in kernel mode and execute operating system code to perform administrative and housekeeping functions.
- User processes operate in user mode to execute user programs and utilities
The various states over here are:
- Created: Process is newly created and is not ready to run.
- User Running: The process is currently executing in user mode.
- Kernel Running: The process is currently running in kernel mode.
- Ready to run, in memory: The process is ready to run and is waiting for the Kernel to schedule it.
- Ready to run, swapped: The process is ready to run, but is currently no in the main memory and is waiting for the swapper to swap it to the main memory.
- Sleep, Swapped: A blocked state wherein the process is awaiting an event and has been swapped to secondary storage.
- Asleep in memory: A blocked state wherein the process is waiting for an event to occur and is currently in the main memory.
- Pre-empted: Process is running from kernel to user mode. But the kernel pre-empts it and does a process switch and schedules another process.
- Zombie: Process no longer exists. It still leaves behind a record of it for its parent process to access.
Working:
- A process after creation is not immediately put into Ready state.
- Instead it is put to Created state. This is done so that we create a process without enough memory available to run.
- Then it can move to Ready to run in memory or Ready to run swapped state based on the available memory.
- Now, when it arrives in memory, based on the scheduling we move to kernel mode or User mode as per the requirements. Interrupts in between will send the system into a Sleep state (Blocked).
- When the process finishes execution, it invokes an Exit system call and goes into Zombie state.