10
CPU SCHEDULING T S PRADEEP KUMAR

Lecture 7 cpu scheduling

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Lecture 7   cpu scheduling

CPU SCHEDULINGT S PRADEEP KUMAR

Page 2: Lecture 7   cpu scheduling

CPU Burst and IO Burst

Page 3: Lecture 7   cpu scheduling

CPU Burst and IO Burst• Burst time is an assumption of how long a process

requires the CPU between I/O waits.• It can not be predicted exactly, before a process starts. • It means the amount of time a process uses the CPU for a

single time. (A process can use the CPU several times before complete the job)

Page 4: Lecture 7   cpu scheduling

CPU Scheduler• Short term scheduler is used• Scheduler selects the processes from the ready list and

allocates the CPU to that process.• Ready queue may be

• FIFO• Priority queue• Tree• Unordered list• Or any list

Page 5: Lecture 7   cpu scheduling

Scheduling Decisions

1. When a process switches from the running state to the waiting state

2. When a process switches from the running state to the ready state

3. When a process switches from the waiting state to the ready state

4. When a process terminates

1 and 4 uses Non Preemptive Scheduling

2 and 3 uses Preemptive Scheduling

Page 6: Lecture 7   cpu scheduling

Non preemptive Scheduling• Windows 3.1 uses non preemptive scheduling• once the CPU has been allocated to a process, the

process keeps the CPU until it releases the CPU either by terminating or by switching to the waiting state.

• No special hardware (ex. timer)is needed for non preemption.

Page 7: Lecture 7   cpu scheduling

Preemptive Scheduling• All the OS these days uses preemptive scheduling• The hardware and the kernel has to be redesigned for

preemptive scheduling• Under preemption,

• A task which is running under a CPU may be going to a ready state, if another high priority task running under a CPU

• Upon completion, then the task will resume based on the priorities of the other tasks in the ready queue.

• System calls are generated using Processes• Kernel important data can be affected if preemption happens in

between, so kernel has to be designed for accepting these changes.

• The kernel will not preempt a process while the kernel data structures are in an inconsistent state

Page 8: Lecture 7   cpu scheduling

Dispatcher• The dispatcher is the module that gives control of the

CPU to the process selected by the short-term scheduler.• Switching context• Switching to user mode• Jumping to the proper location in the user program to restart that

program

• The dispatcher should be fast enough as it is invoked during every context switch.

• The time it takes for the dispatcher to stop one process and start another running is known as the dispatch latency

Page 9: Lecture 7   cpu scheduling

Scheduling criteria• CPU Utilisation

• Range from 0 to 100 • Upto 40% for lightly loaded system, 90% for heavily loaded

• Throughput• Number of processes/hour

• Turnaround time• How long it takes to execute a process• The interval from the time of submission of a process to the time of

completion is the turnaround time• Te_cpu_io+Tmem+Tready_queue

• Waiting time• Time for a process to wait in the ready queue

• Response Time• the time from the submission of a request until the first response is

produced

Page 10: Lecture 7   cpu scheduling

Scheduling criteria• Maximize

• throughput and • CPU utilisation

• Minimize • Turnaround, • Waiting time• Response time.