



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Module code OPS- 311
Module title Operating Systems 1
Department CSIS
Submitted to Mr. D. Nkavea
Submitted by Kelvin Maruwasa – BIT/23/ME/ Due Date March 5, 2025
In operating systems, maximum utilization of CPU and minimal response and waiting times is very important. To ensure the maximum utilization of CPU with minimal response and waiting times, a process called CPU scheduling is used. CPU scheduling is the process that manages the allocation of CPU resources to processes that are ready to be executed. The process of selecting a process from the ready queue to be allocated the resources is done by a CPU scheduler. The CPU scheduler use a set of rules or procedures called CPU scheduling algorithms to determine the process to be allocated resources. These algorithms are grouped into two main categories namely pre-emptive and non-pre-emptive CPU scheduling algorithms. In this discussion much emphasis is on these two main categories of CPU scheduling algorithms.
PREEMPTIVE SCHEDULING ALGORITHMS Pre-emptive also known as cooperative scheduling, the operating system interrupts a running process to allocate CPU resource to another process based on time sharing or priority policies. The interrupted process is pushed to ready state. The decision to pre-empt a process maybe made when a new process arrives, an interrupt blocking a process into ready state occurs or a clock-interrupt occurs. Examples of these algorithms are:
1. ROUND ROBIN Round Robin is an algorithm that uses periodically generated clock-interrupt to block a running process and place it into ready state. All processes that are in ready state are stored in ready queue. Once the process is placed in ready state the next process is selected on First Come First Serve basis (FCFS) also known as First In First Out (FIFO). Each process is given a time slice before being pre-empted using a technique called time slicing. Round Robin follow the below procedure to determine CPU time allocation: A. Round Robin divides CPU time into fixed time slices called time quantum. B. Each process in the ready queue is allocated a fixed time quantum. C. At the end of each time quantum the processes are switched. Processes that are running are suspended and the Round Robin scheduler is invoked to select another
processes have similar arrival time they are processed according to their order in the input queue or ready queue.
2. SHORTEST JOB FIRST (SJF) It is also known as Shortest Process Next (SPN). In this algorithm the scheduler selects the process with the shortest expected processing time. Whenever a process with the shortest expected time joins the ready queue, it is placed at the beginning of the ready queue and is processed next after the running process terminates or reaches waiting state. Whenever expected processing times of multiple processes are similar they’re processed based on First Come First Serve and when both arrival and expected processing times are similar the next process is selected based on arrangement of the processes in the ready queue. 3. HIGHEST RESPONSE RATIO NEXT In this algorithm, the process with the highest response ratio is executed first. The response ration is calculated by using the formula R = (w + s)/ s, where R is the response ratio, w is the time spent waiting for the processor and s is the expected service time. The shortest processes are processed first because they usually have a high response ratio however a long process that has a high waiting time might be processed first over a short process because waiting time increases the response ratio.
Even though most of the algorithms have distinct categories either pre-emptive or Non- pre-emptive, some algorithms do have both characteristics depending on the scenario thereby fitting in both categories. An example of these algorithms is:
1. PRIORITY SCHEDULING ALGORITHM In Priority scheduling algorithm the next process is selected based on the priority of the process. Each process is assigned a priority and the process with the highest priority is processed next. There are two types of priority algorithm namely;
A. Static priority algorithm
Under static priority the priorities are assigned when creating a process and priorities are fixed meaning priorities cannot change during execution.
B. Dynamic priority algorithm Dynamic priorities are flexible in the sense that the priorities might change during execution due to factors like process age which is the total waiting time of that process. Processes that have waited for a long time to be allocated CPU time are given a high priority to avoiding starvation. Priority scheduling algorithms implemented both preemptively or non-pre-emptive.
ADVANTEAGES AND DISADVANTAGES OF PRE-EMPTIVE AND NON-PRE- EMPTIVE CPU SCHEDULING ALGORITHMS.
PRE-EMPTIVE ADVANTAGES
DISADVANTAGES
DISADVANTAGES
Reference