Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Notes  >  Operating System  >  Process Scheduler & States of a Process

Process Scheduler & States of a Process | Operating System - Computer Science Engineering (CSE) PDF Download

Process Schedulers in Operating System

There are three types of process scheduler: 

  1. Long Term or job scheduler: It brings the new process to the ‘Ready State’. It controls Degree of Multi-programming, i.e., number of process present in ready state at any point of time. It is important that the long-term scheduler make a careful selection of both IO and CPU bound process. IO bound tasks are which use much of their time in input and output operations while CPU bound processes are which spend their time on CPU. The job scheduler increases efficiency by maintaining a balance between the two.
  2. Short term or CPU scheduler: It is responsible for selecting one process from ready state for scheduling it on the running state. Note: Short-term scheduler only selects the process to schedule it doesn’t load the process on running.  Here is when all the scheduling algorithms are used. The CPU scheduler is responsible for ensuring there is no starvation owing to high burst time processes.
    Dispatcher is responsible for loading the process selected by Short-term scheduler on the CPU (Ready to Running State) Context switching is done by dispatcher only. A dispatcher does the following: 
    • Switching context.
    • Switching to user mode.
    • Jumping to the proper location in the newly loaded program.
  3. Medium-term scheduler: It is responsible for suspending and resuming the process. It mainly does swapping (moving processes from main memory to disk and vice versa). Swapping may be necessary to improve the process mix or because a change in memory requirements has overcommitted available memory, requiring memory to be freed up. It is helpful in maintaining a perfect balance between the I/O bound and the CPU bound. It reduces the degree of multiprogramming.

Process States in OS

We'll learn about 'Process States' and the many states processes that occur throughout the lifespan of a process in this post. The states that the process can have differed from one Operating System to the next. However, just a few frequent states are depicted in the diagram.
Process Scheduler & States of a Process | Operating System - Computer Science Engineering (CSE)

Let's first understand what is a process. The process is defined as any program that goes under execution. One example of creating the process is using the fork() system call. The parent process uses a fork() system call which will create the child process. It is possible that at the same time multiple processes are created and stored in memory.
Whenever the process creation is taking place process is in a new state and when the process gets terminated it is in the terminated state or completed state.
The states of the process are stored in Process Control Block(PCB). PCB is a special data structure that stores information about the process.
Let’s learn about the various states a process can go through in detail in the next section along with the process state diagram.

List of States of the Process

New State
This is the first state of the process life cycle. When process creation is taking place, the process is in a new state.

Ready State
When the process creation gets completed, the process comes into a ready state. During this state, the process is loaded into the main memory and will be placed in the queue of processes which are waiting for the CPU allocation.
When the process is in the creation process is in a new state and when the process gets created process is in the ready state.

Running State
Whenever the CPU is allocated to the process from the ready queue, the process state changes to Running.

Block or Wait State
When the process is executing the instructions, the process might require carrying out a few tasks which might not require CPU. If the process requires performing Input-Output task or the process needs some resources which are already acquired by other processes, during such conditions process is brought back into the main memory, and the state is changed to Blocking or Wait for the state. Process is placed in the queue of processes that are in waiting or block state in the main memory.

Terminated or Completed
When the entire set of instructions is executed and the process is completed. The process is changed to terminated or completed state.During this state the PCB of the process is also deleted.
Process Scheduler & States of a Process | Operating System - Computer Science Engineering (CSE)

It is possible that there are multiple processes present in the main memory at the same time.

Suspend Ready
So whenever the main memory is full, the process which is in a ready state is swapped out from main memory to secondary memory. The process is in a ready state when goes through the transition of moving from main memory to secondary memory, the state of that process is changed to Suspend Ready state. Once the main memory will have enough space for the process, the process will be brought back to the main memory and will be in a ready state.
Process Scheduler & States of a Process | Operating System - Computer Science Engineering (CSE)

It’s possible that the process is waiting or blocked state can be swapped out to secondary memory. Let’s understand in which state process in waiting or block state will go.

Suspend Wait or Suspend Blocked
Whenever the process that is in waiting for state or block state in main memory gets to swap out to secondary memory due to main memory being completely full, the process state is changed to Suspend wait or Suspend blocked state.
Process Scheduler & States of a Process | Operating System - Computer Science Engineering (CSE)Let’s conclude what we have learnt so far.

CPU and IO Bound Processes

If the process is intensive in terms of CPU operations then it is called CPU bound process. Similarly, If the process is intensive in terms of I/O operations then it is called IO bound process.

Types of schedulers

  1. Long term – performance: Makes a decision about how many processes should be made to stay in the ready state, this decides the degree of multiprogramming. Once a decision is taken it lasts for a long time hence called long term scheduler.
  2. Short term – Context switching time: Short term scheduler will decide which process to be executed next and then it will call dispatcher. A dispatcher is a software that moves process from ready to run and vice versa. In other words, it is context switching.
  3. Medium term – Swapping time: Suspension decision is taken by medium term scheduler. Medium term scheduler is used for swapping that is moving the process from main memory to secondary and vice versa.

Multiprogramming: We have many processes ready to run. There are two types of multiprogramming:

  1. Pre-emption: Process is forcefully removed from CPU. Pre-emption is also called as time sharing or multitasking.
  2. Non pre-emption: Processes are not removed until they complete the execution.

Degree of multiprogramming
The number of processes that can reside in the ready state at maximum decides the degree of multiprogramming, example: if the degree of programming = 100, this means 100 processes can reside in the ready state at maximum.

The document Process Scheduler & States of a Process | Operating System - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Operating System.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
10 videos|99 docs|33 tests

Top Courses for Computer Science Engineering (CSE)

FAQs on Process Scheduler & States of a Process - Operating System - Computer Science Engineering (CSE)

1. What is a process scheduler in an operating system?
Ans. A process scheduler in an operating system is responsible for determining which processes should be allocated the CPU (Central Processing Unit) and for how long. It is a part of the operating system's kernel and ensures efficient utilization of the CPU by managing the execution of processes.
2. What are the different states of a process in an operating system?
Ans. The different states of a process in an operating system are: 1. New: This is the initial state when a process is being created but has not yet started its execution. 2. Ready: In this state, the process is waiting to be assigned to a processor for execution. 3. Running: The process is currently being executed by the CPU. 4. Waiting: The process is waiting for a particular event to occur, such as the completion of an I/O operation. 5. Terminated: The process has finished its execution and has been terminated.
3. What is the role of a process scheduler in managing process states?
Ans. The process scheduler plays a crucial role in managing process states. It determines when a process should transition from one state to another based on various factors such as priority, time-slicing, and resource availability. For example, it may decide to move a process from the running state to the waiting state if it requires I/O operations. The process scheduler ensures efficient utilization of resources and maintains a balance between responsiveness and throughput.
4. How does a process scheduler prioritize processes in an operating system?
Ans. A process scheduler prioritizes processes in an operating system using various scheduling algorithms. Some commonly used algorithms are: 1. First-Come, First-Served (FCFS): Processes are executed in the order they arrive. No priority is given. 2. Shortest Job Next (SJN): The process with the shortest burst time is executed next. 3. Round Robin (RR): Each process is assigned a fixed time slice, and they take turns executing. 4. Priority Scheduling: Processes are assigned priority levels, and the one with the highest priority is executed first. 5. Multilevel Queue Scheduling: Processes are divided into multiple queues based on priority, and each queue has its own scheduling algorithm. The process scheduler selects the appropriate algorithm based on the system requirements and the characteristics of the processes.
5. How does process scheduling impact the performance of an operating system?
Ans. Process scheduling significantly impacts the performance of an operating system. A well-designed process scheduler can ensure efficient utilization of system resources, improve response times, and maximize throughput. On the other hand, a poorly implemented scheduler can lead to resource underutilization, long waiting times, and decreased overall system performance. Therefore, it is crucial to have an effective process scheduling algorithm that suits the specific needs of the system and the workload it handles.
10 videos|99 docs|33 tests
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Free

,

Process Scheduler & States of a Process | Operating System - Computer Science Engineering (CSE)

,

pdf

,

study material

,

ppt

,

video lectures

,

MCQs

,

Important questions

,

Objective type Questions

,

practice quizzes

,

Sample Paper

,

mock tests for examination

,

Viva Questions

,

Exam

,

Semester Notes

,

Process Scheduler & States of a Process | Operating System - Computer Science Engineering (CSE)

,

Previous Year Questions with Solutions

,

past year papers

,

Process Scheduler & States of a Process | Operating System - Computer Science Engineering (CSE)

,

shortcuts and tricks

,

Extra Questions

,

Summary

;