Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Last Updated: Mar 27, 2024

Process Queues

gp-icon
Operating system track
Free guided path
14 chapters
83+ problems
gp-badge
Earn badges and level up
Operating System

Introduction

The operating system manages many Process queues for each process stage. A Process queue is used to hold process-related program control blocks (PCBs). When a process transitions from one state to another, the process's PCB (Program Control Block) is unlinked from the Process queue and then linked to another state queue where the transition occurs via Process Scheduling.

When a work is accepted, the job scheduler produces the job's PCB (Process Control Blocks) and upgrades it during the execution. The queues are formed by linking these PCBs, not the jobs used to monitor the related jobs.

Recommended Topic, FCFS Scheduling Algorithm, Multiprogramming vs Multitasking

Process Scheduling

Multiprogramming operating systems rely heavily on process scheduling. Process Scheduling removes a currently running job from the processor and picks another task to perform. Process Scheduling divides a process into stages: ready, waiting, and running.

There are two ways of scheduling:

1. Non-Preemptive: The resource cannot be withdrawn from a process in non-preemptive until the process has completed execution. Resources are switched when a running process quits and changes to a waiting state.

2. Preemptive: The operating system provides resources to a process for a set period in preemptive scheduling. During the allocation of resources, the process transitions from running to ready or from waiting to ready. This switching happens because the CPU may grant precedence to other processes and substitute the executing process with a higher priority process.

CPU Scheduling

Process Scheduling Objectives

The following are the objectives of process scheduling:

1. Increase the number of interactive users while maintaining acceptable response times.

2. Strive for a balance of reaction and utilization.

3. It ensures no delays for an indefinite time and enforces priority.

4. It refers to the procedures that hold vital resources.

 

To get details about Demand Paging in OS visit this.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Types of Process Scheduler

Process Schedulers are classified into three types:
 

Types of Process Schedulers

Long-Term Scheduler

A long-term scheduler determines which system should process programs. It uses CPU Scheduling to select and load programs into memory for execution. It manages the degree of multiprogramming and offers a balanced combination of jobs such as I/O bound and CPU bound.

A steady degree of multiprogramming indicates that the average rate of initialization and the average rate of process departure from the system are equal. Many systems, such as time-sharing operating systems, do not have a long-term scheduler since it is only necessary when a process transitions from new to ready.

Medium-Term Scheduler

Medium-term scheduling, which is part of swapping, removes programs from memory. It lowers the amount of multiprogramming and handles the switched-out processes. For enhancing the process mix, swapping is required.

When a current process makes an I/O request, it is suspended, which cannot be performed. As a result, the suspended process is transferred to secondary storage to free up memory for other operations. This is known as switching, and the act of swapping is referred to as switched out or rolled out.

Short-Term Scheduler

A short-term scheduler, often known as a CPU scheduler, boosts system performance based on a predefined set of parameters. This is the process's transition from the ready state to the operating state.

It chooses one of the many processes ready to be executed and assigns the CPU to one of them. It is speedier than long-term schedulers, and it is also known as a dispatcher since it decides which process will be run next.

Process Queues

All PCBs are kept in Process Queues by the OS. The OS has a distinct queue for each process state, and all PCBs in the same execution state are put in the same Process queue. When a process's status changes, its PCB is unbound from the current queue and transferred to the new state queue.

The Operating System manages the following queues:

1. Job Queue: All processes are placed in the work queue at the start. It's kept in backup storage. The long-term scheduler chose a handful of the jobs and placed them in primary storage.

2. Ready Queue: The ready queue is kept in primary memory. We select the job for processing from the ready queue using the short-term scheduler, then dispatch it to the CPU.

3. Waiting Time: If the process in the ready queue requires some actions, such as input/output operations, to complete its execution, the operating system must alter the process status from running to waiting. The context (Program Control Block) is saved in the waiting queue, which the CPU will use after the IO is complete.

Process Queues

Read about Batch Operating System here.

Frequently Asked Questions

What is Process Scheduling in the Operating system?

Process scheduling is the process management activity that manages to remove a running process from the CPU and choose another process based on a particular strategy.

What is a CPU Scheduler?

A short-term scheduler, often known as a CPU scheduler, chooses one of the many processes ready to be executed and assigns the CPU to one of them. It is speedier than long-term schedulers, and it is also known as a dispatcher since it decides which process will be run next.

What does Device Queue consist of?

The device queue comprises stalled processes because an I/O device is unavailable.

What is Preemptive Scheduling?

The operating system provides resources to a process for a set period in preemptive scheduling. During the allocation of resources, the process transitions from running to ready or from waiting to ready.

Conclusion

This article extensively discussed Process Queues, types and working of Process Queues, and implementation of Process Queues in Process Scheduling of Operating systems.
 

Recommended Readings:


Do check out The Interview guide for Product Based Companies as well as some of the Popular Interview Problems from Top companies like Amazon, Adobe, Google, Uber, Microsoft, etc. on Coding Ninjas Studio.

Also check out some of the Guided Paths on topics such as Data Structure and Algorithms, Competitive Programming, Operating Systems, Computer Networks, DBMS, System Design, etc. as well as some Contests, Test Series, Interview Bundles, and some Interview Experiences curated by top Industry Experts only on Coding Ninjas Studio.

Nevertheless, you may consider our paid courses to give your career an edge over others!

Do upvote our blogs if you find them helpful and engaging!

Happy Learning!

Previous article
Look Disk Scheduling
Next article
States of a Process
Guided path
Free
gridgp-icon
Operating system track
14 chapters
83+ Problems
gp-badge
Earn badges and level up
Live masterclass