copy of final ppt

28
Process Scheduling Neha Bansal 1055 Nikita Agarwal 1056 Nirmal Porwal 1057 Nishant Namdeo 1058 Nitesh Vakhare 1059 Vishwas Reddy 1060 IACSD - Pune 1

Upload: rohit-kshirsagar

Post on 21-Jul-2016

23 views

Category:

Documents


0 download

DESCRIPTION

ppt

TRANSCRIPT

Page 1: Copy of Final Ppt

1

Process Scheduling

Neha Bansal 1055Nikita Agarwal 1056Nirmal Porwal 1057Nishant Namdeo 1058Nitesh Vakhare 1059Vishwas Reddy 1060

IACSD - Pune

Page 2: Copy of Final Ppt

2

Overview

1. Process 2. Process states 3. Process Scheduling 4. Type of Schedulers.5. Basic Concepts.6. CPU Scheduler.

a. Non-preemptive scheduling.b. Preemptive scheduling.

7. Scheduling Criteria.

Page 3: Copy of Final Ppt

3

8. Scheduling Algorithms.a. FCFS .b. SJF.c. Priority.d. Round Robin.

9. Time Quantum and Context Switch Time.10.Any Queries ?

Page 4: Copy of Final Ppt

4

1. What is process ?The process is a program in execution. It’s a

unit of work in a system.

2. Process statesNew -The process is being created.Ready -The process is waiting to be assigned to a processor.Running -Instructions are Being executed.Waiting -The process is waiting for some event to occur(such as an I/O completion or reception of signal).Terminated -The process has finished execution.

Page 5: Copy of Final Ppt

New Terminated

Ready

Waiting

Running

Admitted

I/O or event Completion

Scheduler Dispatch

InterruptExit

I/O or Event Wait

Figure 1 : Diagram of process states

Page 6: Copy of Final Ppt

3. What is process scheduling ?

When a computer is multi-programmed, it frequently has multiple processes competing for the CPU at the same time. Multiprogramming is helpful to maximize CPU utilization.

Page 7: Copy of Final Ppt

4. Type of schedulers.

a. Long-term schedulingThe decision to add to pool of processes to be

executed.b. Mid-term scheduling

The decision to add to the number of processes that are partially or fully in memory.c. Short-term scheduling

Decision as to which available process will be executed.d. I/O scheduling

Decision as to which process’s pending request shall be handled by an available I/O device.

Page 8: Copy of Final Ppt

5. Basic Concepts

A

B

Long CPU Burst IO Request (wait)

Short CPU burst IO Request (wait) Time

A spends most of his time computing, it is called compute-boundB spends most of his time waiting for I/O, it is called I/O-bound

Page 9: Copy of Final Ppt

Histogram of CPU-burst Times

Figure 2 : Histogram of CPU-burst Times

Page 10: Copy of Final Ppt

10

6. CPU scheduler

a. Non preemptive Scheduling- picks a process to run- lets it run until it blocks, terminates or voluntary releases the CPU- after clock interrupt, resume the process that was running before

b. Preemptive Scheduling- picks a process to run- after a maximum amount of some fixed time suspends it (if still running)- picks another process to run (if any available)- requires clock

Page 11: Copy of Final Ppt

11

7 . Scheduling Criteria

CPU utilization – keep the CPU as busy as possible

Throughput – Number of processes that complete their execution per time unit

Turnaround time –Amount of time to execute a particular process

.

Page 12: Copy of Final Ppt

Response time –Amount of time it takes from when a request was submitted until the start of a response (not time for output) (for time- sharing environment)

Waiting time – Amount of time a process has been waiting in the ready queue. Quite representative

7 . Scheduling Criteria (Contd..)

Page 13: Copy of Final Ppt

13

8.Scheduling Algorithms

a. FCFS (First Come First Served)b. SJF (Shortest Job First)c. Priority Schedulingd. RR (Round Robin Scheduling)

Page 14: Copy of Final Ppt

a. FCFS (First Come First Served)Is non-preemptive

Process Burst TimeP1 24 P2 3 P3 3

Suppose that the processes arrive in the order: P1 , P2 , P3 , all at the same time. The Gantt Chart for the schedule is:

Waiting time for P1 = 0; P2 = 24; P3 = 27Average waiting time: (0 + 24 + 27)/3 = 17

P1 P2 P3

24 27 300

Page 15: Copy of Final Ppt

• Suppose that the processes arrive in the order

P2 , P3 , P1 .

• The Gantt chart for the schedule is:

• Waiting time for P1 = 6; P2 = 0; P3 = 3

• Average waiting time: (6 + 0 + 3)/3 = 3• Much better than previous case.• Convoy effect short process behind long

process.

a. FCFS - First Come First Served (contd..)

P1P3P2

63 300

Page 16: Copy of Final Ppt

0 5 10 15 20

12345

Figure 3 : FCFS working concept

a. FCFS - First Come First Served (contd..)

Page 17: Copy of Final Ppt

b. Shortest-Job-First (SJF) Scheduling

Associate with each process the length of its next CPU burst.

Use these lengths to schedule the process with the shortest time.

Two schemes: Non-preemptive – Once CPU given to the process it

cannot be preempted until completes its CPU burst.Preemptive – If a new process arrives with CPU burst

length less than remaining time of current executing process, preempt.This scheme is know as the Shortest-Remaining-Time-First (SRTF).

Page 18: Copy of Final Ppt

Process Arrival Time Burst TimeP1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4

Gantt Chart

Average waiting time = (0 + 6 + 3 + 7)/4 - 4

b. SJF (contd..)

P1 P3 P2

73 160

P4

8 12

• Non-Preemptive Example

Page 19: Copy of Final Ppt

b. SJF (contd..) • Preemptive Example

Process Arrival Time Burst TimeP1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4

Gantt Chart

Average waiting time = (9 + 1 + 0 +2)/4 - 3

P1 P3P2

42 110

P4

5 7

P2 P1

16

Page 20: Copy of Final Ppt

0 5 10 15 20

12345

b. SJF (contd..)

Page 21: Copy of Final Ppt

c. Priority Scheduling

•A priority number (integer) is associated with each process,

• Internal, e.g., by resource needs• External, e.g., by user priority

•The CPU is allocated to the process with the highest priority (smallest integer highest priority).

• Non-preemptive or PreemptiveExample

Proc ArrivalBurst PriorityP1 0 10 3P2 1 1 1P3 2 2 3P4 4 1 4P5 8 5 2

Page 22: Copy of Final Ppt

• SJF is a priority scheduling where priority is the predicted next CPU burst time.

• Problem Starvation – low priority processes may never execute.

• Solution Aging – as time progresses increase the priority of the process.

c. Priority Scheduling

Page 23: Copy of Final Ppt

23

d. Round Robin (RR)

Each process gets a small unit of CPU time (time quantum), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue.

If there are n processes in the ready queue and the time quantum is q, then each process gets 1/n of the CPU time in chunks of at most q time units at once. No process waits more than (n-1)q time units.

Page 24: Copy of Final Ppt

Example of RR with Time Quantum = 20

Process Burst TimeP1 53P2 17P3 68P4 24

The Gantt chart is:

P1 P2 P3 P4 P1 P3 P4 P1 P3 P3

0 20 37 57 77 97 117 121 134 154 162

Page 25: Copy of Final Ppt

0 5 10 15 20

12345

d. Round Robin (RR) Concept

Page 26: Copy of Final Ppt

9. Time Quantum and Context Switch Time.

Performance• large FIFS

• q small q must be large with respect to context switch, otherwise overhead is too high.

Typically, higher average turnaround than SJF, but better response.

Page 27: Copy of Final Ppt

Any queries ?

Page 28: Copy of Final Ppt

28

Thank you !