You are on page 1of 7

CPU SCHEDULING

• The storage structure for the ready queue and the algorithm used to select the next process are not necessarily a FIFO queue. it is the job of the CPU Scheduler ( a.k. the short-term scheduler ) to select another process from the ready queue to run next.a. .CPU Scheduler • Whenever the CPU becomes idle.

Otherwise the system is said to be preemptive. When a process switches from the waiting state to the ready state. 4. the system is said to be non-preemptive. . for example in response to an interrupt. When a process switches from the running state to the waiting state. Macs used non-preemptive prior to OSX. until it either voluntarily blocks or until it finishes. say at completion of I/O or a return from wait( ). When a process terminates. Under these conditions. and pre- emptive since then. When a process switches from the running state to the ready state. 3. or cooperative. 2. • Windows used non-preemptive scheduling and started using pre-emptive scheduling with Win95. such as for an I/O request or invocation of the wait( ) system call.• CPU scheduling decisions take place under one of four conditions: 1. • If scheduling takes place only under conditions 1 and 4. once a process starts running it keeps running.

Classification of short term scheduling strategies: 1. the running process is allowed to continue until either it is blocked or completes its execution. . Preemptive – scheduling strategy where the CPU is suspended when a higher priority process in in the ready queue. Non-preemptive – scheduling strategy when even higher priority process is ready. 2.

4. Turnaround time – time between the submission of a job to the time of completion. 6. 2. 3. Response time – time from the submission of the job to the time the job is first allocated in the CPU. Throughput – number of jobs which are completed per unit time. 5.Algorithm properties: 1. Waiting time – time spent to get into memory and time spent waiting in the ready queue. . Fairness – each process must get its fair share of the CPU. CPU utilization – ratio of useful computing time over the total time used.

• When a process is given the CPU. a timer is set for whatever value has been set for a time quantum. it will be executed and the current job is preempted. except that CPU bursts are assigned with limits called time quantum.Scheduling Algorithms • First-Come First-Serve Scheduling. • If the process finishes its burst before the time quantum timer expires. FCFS • FCFS is very simple . then the process is swapped out of the CPU and moved to the back end of the ready queue . • Shortest Job First (SJF) • an attempt to minimize the mean response time by selecting the job with the shortest execution time. • If the timer goes off first. • Shortest Remaining Processing Time (SRPT) • preemptive version of SJF . If a new arrival has an execution time shorter than the remaining for the current job.Just a FIFO queue. in which each job is assigned a priority and the job with the highest priority gets scheduled first • Round Robin Scheduling • Round robin scheduling is similar to FCFS scheduling. • Priority Scheduling • Priority scheduling is a more general case of SJF. like customers waiting in line. then it is swapped out of the CPU just like the normal FCFS algorithm.

• FCFS • SJF • PRIORITY .