Process States in Operating System

Process:

process is a program at the time of execution. A process is more than the program code. It includes the program counter, the process stack, and the contents of the process register, etc.

Process States :

When a process executes, it changes the state, generally, the state of the process is determined by the current activity of the process.

process states

Each process may be in one of the following states :

1. New: The process is being created.
2. Running: The process is been executing.
3. Waiting: The process is waiting for some event to occurs.
4. Ready: The process is waiting to be assigned to a processor.
5. Terminate: The process has finished execution.

The important thing is only one process can be running in any processor at any time. But many processes may be in ready and waiting states. The ready process is loaded into a “Ready Queue“.

Explanation of Process States:

New -> Ready: The operating system creates a process and prepares the process to be executed, then the operating system moved the process into “Ready Queue“.

Ready -> Running: When it is time to select a process to run. The operating system selects one of the jobs from the ready queue and moves the process from the ready state to the running state.

Running -> Terminated: When the execution of a process has completed, then the OS terminates that process from running state.

Running -> Ready: When the time slot of the processor expired, then the operating system shifted the running process to the ready state.

Ready -> Running: When it is time to select a process to run. The OS selects one of the jobs from the ready queue and moves again the process from the ready state to the running state.

Running -> Waiting: A process is put into the waiting state. If the process needs an event to occur or an I/O device. The operating system doesn’t provide the I/O device then the process moved to the waiting state by the operating state.

Waiting -> Ready: The process in the blocked state is moved to the ready state when the event for which it has been waiting occurs.

Thread: A process is divided into several light-weight processes, each light-weight process is said to be a thread. The thread has a program counter that keeps the tracks of which instruction to execute next, if process registers, which hold its current working variables. It has a stack which contains the executing thread history.
We can Difference between Process and Thread given below:




Process Thread
1. Process can't share the memory.1. Threads can share memory and files.
2. In process, execution is very slow.2. In thread, execution is very fast.
3. It takes more time to create a process. 3. It takes less time to create a process.
4. It takes more time to complete the execution and terminate.4. It takes less time to complete the execution and terminate.
5. Process is loosely coupled.5. Theads are tightly coupled.
6. Processes are not suitable for parallel activities.6. Threads are suitable for parallel activities.
7. System calls are required to communicate each other. 7. System calls are not required.
8.Implementing the communication between processes is difficult. 8. Communication between two threads are very easy.

Recommended Posts:

Operating System
    1. Generation of Computer 1st to 5th
    2. Memory Hierarchy in Computer Architecture
    3. Interrupts in Computer Architecture
    4. Cache Memory Mapping Techniques
    5. Direct Memory Access in Computer Architecture
    6. Functions and Services of OS
    7. Major Achievements of OS
    8. Types of Operating Systems
    9. Characteristics of Modern OS
    10. Architecture of Windows and Linux
    11. Process States in OS
    12. Difference Between Program and Process
    13. Process Control Block (PCB) in OS
    14. Life Cycle of Thread in OS
    15. Difference between User Level Thread and Kernel Level Thread