Cpu Scheduling in Time Sharing Operating System

Author : Er R Banger | Published On : 03 Nov 2023

A time-sharing operating system is a type of operating system that allows multiple users or processes to concurrently share the same system resources, such as the CPU, memory, and peripherals. It enables each user or process to use the system at various terminals simultaneously, reducing response times and allowing for more effective use of system resources. Some key features of a time-sharing operating system include:

CPU Scheduling: A time-sharing operating system uses CPU scheduling to provide each user with a small portion of CPU time, known as a time slice or quantum. An alarm clock mechanism sends an interrupt signal to the CPU after every time slice, allowing the operating system to switch to another process.

Memory Protection: A time-sharing operating system must have a memory protection mechanism to prevent one job's instructions and data from interfering with other jobs.

Equal Opportunity: Each task gets an equal opportunity, i.e. equal time quantum for execution.

Minimized Response Time: The main aim of a time-sharing operating system is to minimize the response time of the CPU.

Cost-Effective: Time-sharing operating systems may be more cost-effective for businesses because they permit multiple users to use the system without needing to purchase individual licenses.

How Does CPU Scheduling Work in Time-Sharing Operating System?

In a time sharing operating system, CPU scheduling is used to provide each user with a small portion of CPU time, known as a time slice or quantum. The operating system uses scheduling algorithms, such as round-robin or priority-based scheduling, to determine which process should be allocated the CPU next.

The time slice is usually a few milliseconds long, and the operating system switches between processes after each time slice, allowing each user to have the illusion of having dedicated access to the system while effectively sharing resources in a time-sliced manner. The CPU scheduler is responsible for selecting the next process to run based on the scheduling algorithm used.

The CPU scheduler must also ensure that each process gets a fair share of the CPU time and that no process is starved of CPU time. The CPU scheduler must also perform context switching, which involves saving and restoring the execution context of each process, to switch between processes. The main aim of CPU scheduling in a time-sharing operating system is to minimize the response time of the CPU.

Difference in between Time Sharing OS and Batch Operating System

Some differences between the two types of operating systems are:

Batch Operating System:

·         Users do not interact with the computer directly.

·         Each user prepares their job on an off-line device like punch cards and submits it to the computer operator.

·         Jobs with similar needs are batched together and run as a group.

·         The operating system is designed to maximize processor use.

Time-Sharing Operating System:

·         Multiple users can use the system at various terminals simultaneously.

·         Each user gets a small portion of CPU time, known as a time slice or quantum.

·         The operating system is designed to minimize response time.

·         CPU scheduling and multiprogramming are used to provide each user with a small portion of time.

CPU Scheduling Algorithms Used in Time Sharing OS

There are several CPU scheduling algorithms used in time-sharing operating systems. Some of the most common ones are:

Round Robin Scheduling: This algorithm is a simple and widely used CPU scheduling algorithm in which each process is given a fixed time slice or quantum, and the CPU is switched between processes after each time slice.

Priority-Based Scheduling: In this algorithm, each process is assigned a priority, and the CPU is allocated to the process with the highest priority.

Shortest Job First Scheduling: This algorithm selects the process with the shortest burst time or execution time. It is useful in reducing the average waiting time of processes and improving the overall system performance.

Multiple-Level Queues Scheduling: This algorithm separates the ready queue into various separate queues based on specific properties of the process, such as priority or memory size. Each queue has its own scheduling algorithm, and processes are assigned to a queue based on their properties.

ATS Scheduling: This is a novel time-sharing CPU scheduling algorithm based on feature similarities. It aims to minimize the time cost in time-shared operating systems and is designed to be more efficient than traditional scheduling algorithms.