Docsity

CPU Scheduling: Pre-emptive and Non-pre-emptive Techniques, Schemes and Mind Maps of Operating Systems

Partial preview of the text

Download CPU Scheduling: Pre-emptive and Non-pre-emptive Techniques and more Schemes and Mind Maps Operating Systems in PDF only on Docsity!

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

CPU SCHEDULLING ALGORITHMS

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

  1. Improved average response time. Making them ideal for multi-programming systems.
  2. More reliable since it does not cause denial of service because of no monopoly of CPU time.

DISADVANTAGES

  1. Greater overhead due to high number of context switches.

NON-PRE-EMPTIVE

ADVANTAGES

  1. Lower overhead due to low number of context switches.

DISADVANTAGES

  1. More average response time. Resulting which might result in starvation.

Reference

  1. Dhamdhere, D. M. (2012). Operating Systems: A concept-Based Approach (3rd^ ed.) McGraw Hill.
  2. Dalmia, R., Sinha, A., Verma, R., & Gupta, P. K. (2022). Dynamic ready queue-based process priority scheduling algorithm. arXiv preprint arXiv
  3. Dash, A. R., Sahu, S. K., Samantra, S. K., & Sabat, S. (2015). Characteristic specific prioritized dynamic average burst round robin scheduling for uniprocessor and multiprocessor environment. arXiv preprint arXiv
  4. Dash, A. R., Sahu, S. K., & Samantra, S. K. (2016). An optimized round robin CPU scheduling algorithm with dynamic time quantum. arXiv preprint arXiv
  5. Durbhakula, S. M. (2018). OS scheduling algorithms for improving the performance of multithreaded workloads. arXiv preprint arXiv
  6. Harvay M.Deital, Introduction to Operating System, Addition Wesley Publication Company.
  7. Silberschatz, A., Galvin, P. B., & Gagne, G. (2018). Operating system concepts (10th ed.). Wiley.
  8. Stallings, W. (2018). Operating systems: Internals and design principles (9th ed.). Pearson Education.
  9. Tanenbaum, A. S., & Bos, H. (2015). Modern operating systems (4th ed.). Pearson Education
  10. Yu-Chu Tian, David Charles Levy. (2022). Handbook of real-time computing. Springer.
  11. Vijay Shukla, Operating System, S.K. Kataria & Sons
  12. www.geeksforgeeks.org/cpu-scheduling-in-operating-systems