custom software design

ArticlesHow a Operating System Schedules Processes
custom software design

First let's explain what a process is. A process is a program that is being run on your computer. Today computers allow for multiple programs to run at the same time. These programs can be anything from a Microsoft Word document to your anti-virus software to your background windows programs running on your computer... all at the same time!

So how does your computer magically manage all these programs (or processes how we will refer to them from now on in this article)? This isn't really magic at all but is done through something called multi-programming.

The main objective of multi-programming is to keep on running programs all the time for maximum CPU utilization. Scheduling these processes is the fundamental function of the OS. The task of selecting the processes in memory that are ready to execute, and allocating them to the CPU is performed by the CPU Scheduler. Once this is done, the OS rotates the processes.

custom software design
Below is a sample program that will simulate how processes are scheduled by the computer's operating system:



How to Use CPU Scheduler
STEP 1: Select the # of CPU processes to use (1-10).

STEP 2: Select the scheduling algorithm

STEP 3: If using Round-Robin, then select the quantum

STEP 4: If using Priority Scheduling, type in the priorities for each process

STEP 5: Type in the burst times for each process. You can also press the "Random" button which will automatically generate random values for the burst times and priorities.

STEP 6: Press the "Calculate" button to determine average wait time and average turnaround time

* NOTE *: Use the Scroll bar at the bottom of the screen to scroll through the Gantt chart. Swipe finger on Mobile device to scroll Gantt chart.

* NOTE *: If you decide to change any information you entered, you must press the "Calculate" button again.
CPU Scheduling Algorithms:
FCFS - FIRST COME FIRST SERVE FCFS - FIRST COME FIRST SERVE - When a process enters CPU, the CPU to allocated to that process. The next process stays in a queue until the burst time is complete.

FCFS - FIRST COME FIRST SERVE SJF - SHORTEST JOB FIRST - Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time.

PRIORITY PRIORITY - A priority number (integer) is associated with each process The CPU is allocated to the process with the highest priority (largest integer highest priority first).

ROUND ROBIN ROUND ROBIN - Each process gets a small unit of CPU time (time quantum), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue. If there are n processes in the ready queue and the time quantum is q, then each process gets 1/n of the CPU time in chunks of at most q time units at once. No process waits more than (n-1)q time units.

CPU Scheduling Terminology:

Burst Time Burst Time - actual time that is required to complete execution of particular task or process.

Wait Time Wait Time - amount of time a process has been waiting in the ready queue

Turnaround Time Turnaround Time (T/A) - amount of time to execute a particular process

Quantum Quantum - For Round Robin, the CPU will switch processes based on this value until the processes burst time is used up

CPU Utilizatio CPU Utilization - keep the CPU as busy as possible

Throughput Throughput - # of processes that complete their execution per time unit

Response Time Response Time - amount of time from when a request was submitted until the first response is produced.

Also visit our article on how a computer manages memory for these processes.