Anzeige

Osy ppt - Copy.pptx

13. Jan 2023
Anzeige

Más contenido relacionado

Anzeige

Osy ppt - Copy.pptx

  1. WELCOME
  2. Presentation on “ Different CPU scheduling algorithms, make comparative chart to calculate turnaround and waiting time ”
  3. CPU Scheduling is a process of determining which process will own CPU for execution while another process is on hold. The main task of CPU scheduling is to make sure that whenever the CPU remains idle, the OS at least select one of the processes available in the ready queue for execution. The selection process will be carried out by the CPU scheduler. It selects one of the processes in memory that are ready for execution. Introduction : Scheduling is one of the basic functions of any operating system, because scheduling of all the computer resources is done before their user. The CPU the most essential computer resource.
  4. Types of CPU scheduling Algorithms: There are mainly six types of process scheduling algorithms 1)First Come First Serve (FCFS) 2)Shortest-Job-First (SJF) Scheduling 3)Shortest Remaining Time 4)Priority Scheduling 5)Round Robin Scheduling 6)Multilevel Queue Scheduling
  5. First Come First Serve (FCFS) :-  In the "First come first serve" scheduling algorithm, as the name suggests, the process which arrives first, gets executed first, or we can say that the process which requests the CPU first, gets the CPU allocated first.  First Come First Serve, is just like FIFO (First in First out) Queue data structure, where the data element which is added to the queue first, is the one who leaves the queue first.  This is used in Batch Systems.  It's easy to understand and implement programmatically, using a Queue data structure, where a new process enters through the tail of the queue, and the scheduler selects process from the head of the queue.  A perfect real life example of FCFS scheduling is buying tickets at ticket counter.
  6. Advantages of FCFS:- 1) It is easy to implement. 2) It is easy to understand. 3) First come, First serve Disadvantages of FCFS : – 1) The process with less execution time suffer i.e. waiting time is often quite long. 2) Favors CPU Bound process then I/O bound process. 3) Here, first process will get the CPU first, other processes can get CPU only after the current process has finished it’s execution. Now, suppose the first process has large burst time, and other processes have less burst time, then the processes will have to wait more unnecessarily, this will result in more average waiting time, i.e., Convey effect.
  7. Ex : Gantt chart of the example Turnaround Time for p1= (24-0) = 24 Turnaround Time for p2= (27-0) = 27 Turnaround Time for p3= (32-0) = 32 Average Turnaround Time = (24+27+32)/3 =27.67 Waiting Time for p1 = 0 Waiting Time for p2 = 24 Waiting Time for p3 = 27 Average Waiting Time = (0+24+27)/3 = 17 P1 P2 P3 0 24 27 32 Process Burst time P1 24 P2 03 P3 05
  8. 2. Shortest-Job-First (SJF) Scheduling:- Till now, we were scheduling the processes according to their arrival time (in FCFS scheduling). However, SJF scheduling algorithm, schedules the processes according to their burst time. In SJF scheduling, the process with the lowest burst time, among the list of available processes in the ready queue, is going to be scheduled next. However, it is very difficult to predict the burst time needed for a process hence this algorithm is very difficult to implement in the system. Advantages of Shortest Job First (SJF):- Maximum throughput. Minimum average waiting and turnaround time. Disadvantages of Shortest Job First (SJF):- May suffer with the problem of starvation It is not implementable because the exact Burst time for a process can't be known in advance.
  9. 3. Shortest Remaining Time:- This Algorithm is the preemptive version of SJF scheduling. In SRTF, the execution of the process can be stopped after certain amount of time. At the arrival of every process, the short term scheduler schedules the process with the least remaining burst time among the list of available processes and the running process. Once all the processes are available in the ready queue, No preemption will be done and the algorithm will work as SJF scheduling. The context of the process is saved in the Process Control Block when the process is removed from the execution and the next process is scheduled. This PCB is accessed on the next execution of this process. Advantages of Shortest Remaining Time:- 1)Short-burst jobs run fast Disadvantages of Shortest Remaining Time:- 1) Long-burst (CPU intensive) jobs get a long mean waiting time 2) Rely on ability to estimate CPU burst length
  10. 4. Priority Scheduling:- In this tutorial we will understand the priority scheduling algorithm, how it works and its advantages and disadvantages. In the Shortest Job First scheduling algorithm, the priority of a process is generally the inverse of the CPU burst time, i.e. the larger the burst time the lower is the priority of that process. In case of priority scheduling the priority is not always set as the inverse of the CPU burst time, rather it can be internally or externally set, but yes the scheduling is done on the basis of priority of the process where the process which is most urgent is processed first, followed by the ones with lesser priority in order. Processes with same priority are executed in FCFS manner. Advantages of Priority Scheduling:-  The priority of process is selected on the basis of memory requirement, user preference or the requirement of time.  Processes are executed on the basis of priority. So high priority does not need to wait for long which saves time.  It is easy to use.  It is a user friendly algorithm.  Simple to understand.  it has reasonable support for priority.
  11. Disadvantages of Priority Scheduling:-  Some low priority processes waiting indefinitely.  A process will be blocked when it is ready to run but has to wait for the CPU because some other process is running currently.  If a new higher priority process keeps on coming in the ready queue, If the system eventually crashes, all low priority processes get lost. If high priority processes take lots of CPU time, then the lower priority processes may starve and will be postponed for an indefinite time
  12. 5. Round Robin Scheduling:- The name of this algorithm comes from the round-robin principle, where each person gets an equal share of something in turns. It is the oldest, simplest scheduling algorithm, which is mostly used for multitasking. In Round-robin scheduling, each ready task runs turn by turn only in a cyclic queue for a limited time slice. This algorithm also offers starvation free execution of processes. Advantages of Round Robin algorithm:-  It doesn't face the issues of starvation or convoy effect.  All the jobs get a fair allocation of CPU.  It deals with all process without any priority  If you know the total number of processes on the run queue, then you can also assume the worst-case response time for the same process.  This scheduling method does not depend upon burst time. That's why it is easily implementable on the system.  Once a process is executed for a specific set of the period, the process is preempted, and another process executes for that given time period.
  13. Disadvantages of Round Robin algorithm:-  If slicing time of OS is low, the processor output will be reduced.  This method spends more time on context switching  Its performance heavily depends on time quantum.  Priorities cannot be set for the processes.  Round-robin scheduling doesn't give special priority to more important tasks.  Decreases comprehension  Lower time quantum results in higher the context switching overhead in the system.  Finding a correct time quantum is a quite difficult task in this system.
  14. 6. Multilevel Queue Scheduling:- It may happen that processes in the ready queue can be divided into different classes where each class has its own scheduling needs. For example, a common division is a foreground (interactive) process and background (batch) processes. These two classes have different scheduling needs. For this kind of situation Multilevel Queue Scheduling is used . Now, let us see how it works. Ready Queue is divided into separate queues for each class of processes. For example, let us take three different types of process System processes, Interactive processes and Batch Processes. Advantages of Multilevel Queue Scheduling: 1) The processes are permanently assigned to the queue, so it has advantage of low scheduling overhead. Disadvantages of Multilevel Queue Scheduling: 1) Some processes may starve for CPU if some higher priority queues are never becoming empty. It is inflexible in nature.
  15. Comparison Between the different CPU Scheduling Algorithm
  16. Conclusion 1.Scheduling algorithms should not affect the behavior of the. system (same results regardless of schedule). 2.However, the algorithms do impact the system's efficiency and response time. 3.The best schemes are adaptive. To do absolutely best, we'd have to be able to predict the future.
  17. Thank You
Anzeige