Presentation is loading. Please wait.

Presentation is loading. Please wait.

Topic : Process Management Lecture By: Rupinder Kaur Lecturer IT, SRS Govt. Polytechnic College for Girls,Ludhiana.

Similar presentations


Presentation on theme: "Topic : Process Management Lecture By: Rupinder Kaur Lecturer IT, SRS Govt. Polytechnic College for Girls,Ludhiana."— Presentation transcript:

1 Topic : Process Management Lecture By: Rupinder Kaur Lecturer IT, SRS Govt. Polytechnic College for Girls,Ludhiana

2 Index Process Concept Process states Process Control Block Processes Scheduling Schedulers Scheduling Algorithms

3 What is Process? A Process is a program in execution. A process is more than the program code, which is some time known as the text section. It also includes the current activity, as represented by the value of program counter and the contents of the processor’s registers.

4 Operations on Processes Process Creation Process Termination

5 Process States

6 New - The process is being created. Running –It means CPU is actually running the process(i.e. executing the instruction of the process). Waiting –It means that process needs input or produced an output and it is waiting for the completing of that input /output. Ready –This state means that process has been created and now it is ready to be picked up by CPU for execution Terminated - Process has finished execution.

7 Contains information associated with each process Process State - e.g. new, ready, running etc. Process Number – Process ID Program Counter - address of next instruction to be executed CPU registers - general purpose registers, stack pointer etc. Process Control Block

8 Process Control Block (Cont..) CPU scheduling information - process priority, pointer Memory Management information - base/limit information Accounting information - time limits, process number I/O Status information - list of I/O devices allocated

9 Process Scheduling Queues Job Queue - set of all processes in the system Ready Queue - set of all processes residing in main memory, ready and waiting to execute. Device Queues - set of processes waiting for an I/O device. Process migration between the various queues.

10 Schedulers Long-term scheduler (or job scheduler) - selects which processes should be brought into the ready queue. invoked very infrequently (seconds, minutes); may be slow. controls the degree of multiprogramming

11 Short term scheduler (or CPU scheduler) - selects which process should execute next and allocates CPU. invoked very frequently (milliseconds) - must be very fast Medium Term Scheduler swaps out process temporarily balances load for better throughput Schedulers (Cont..)

12 Scheduling Criteria CPU utilization — It is defined as how much time the CPU remain busy.CPU utilization should be as high as possible. Throughput —It is defined as the no. of process completed as per unit time. Turnaround time — It is defined as the time between the submission of job and completion of job. so, it is the time taken the process in the ready queues, time during execution by CPU. It should also be as small as possible.

13 Scheduling Criteria(Cont..) Waiting time — It is define as the time spent by the process in the ready queue.waiting time should be small. Response time — It is define as the time when the first response start coming. It should also be as small as possible.

14 Scheduling Criteria(Cont..) Max CPU utilization Max throughput Min turnaround time Min waiting time Min Response time

15 Types of CPU Scheduling There are two types of CPU scheduling : 1) Preemptive 2)Non-Preemptive

16 Types of CPU Scheduling (cont..) A scheduling discipline is non-preemptive if, once a process has been given the CPU, the CPU cannot be taken away from that process. In nonpreemptive system, - short jobs are made to wait by longer jobs but the overall treatment of all processes is fair. -a scheduler executes jobs in the following two situations. When a process switches from running state to the waiting state. When a process terminates.

17 Types of CPU Scheduling (cont..) A scheduling discipline is preemptive if, once a process has been given the CPU can taken away.

18 Scheduling Algorithms FCFS Round Robin Priority Shortest Job First Feedback Queues

19 FCFS (First Come First Serve) Implementation: As each process becomes ready, it joins the ready queue. When the current process finishes the oldest process is selected next. Characteristics: Simple to implement Nonpreemptive

20 FCFS EXAMPLE : Process Burst Time P1 8 P2 4 P3 9 P4 5 0 8 12 21 26 Average wait =(0+8+12+21)/4 = 10.25 P1 P2 P3 P4

21 SHORTEST JOB FIRST: Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time. Two schemes: 1. non-preemptive – once CPU given to the process it cannot be preempted until completes its CPU burst. 2. 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).

22 SJFS(Non-Preemptive) Process Burst Time P1 7 P2 4 P3 1 P4 4 SJF (non-preemptive) 0 1 5 9 16 Average waiting time = [9 +1+0+5] /4 =3.7 P3 P2 P4 P1

23 SJFS(Preemptive) Example of Preemptive SJF Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 SJF (preemptive) 0 2 4 5 7 11 16 P1P2 P3 P2 P4 P1

24 SJFS(Preemptive) 0 2 4 5 7 11 16 Waiting Time = Waiting Time - No. of times executed – Arrival Time P1 = 11 – 2 – 0 = 9 P2 = 5 – 2 – 2 = 1 P3 = 4 – 0 – 4 =0 P4 = 7 – 0 – 5 =2 Avg. Waiting Time : (9 + 1 + 0 +2)/4 =3 P1P2 P3 P2 P4 P1

25 RR - Round Robin In case of the Round Robin Scheduling,the CPU is allocate to all the processes one by one but for a fixed period of time. This time period is known as time slice or time quantum. After allocating CPU to a process for a fixed time slice, it shifts to next process and so on. It is very efficient algorithm for interactive system because response time is very small in this case. It is similar to FCFS but preemptive in nature.

26 Example of RR Example of RR with Time Quantum = 2 Process Burst Time P1 5 P2 3 P3 3 The Gantt chart is: 0 2 4 6 8 9 10 11 P1P2P3 P1 P2 P3 P1

27 Example of RR The Gantt chart is: 0 2 4 6 8 9 10 11 Waiting time = Waiting Time – No. of times executed P1 = 10 – 4 = 6 P2 = 8 – 2 = 6 P3 = 9 – 2 = 7 Avg. Waiting Time = (6+6+7)/3 = 6.3 P1P2P3 P1 P2 P3 P1

28 Priority Scheduling A priority number (integer) is associated with each process. The CPU is allocated to the process with the highest priority (smallest integer ≡ highest priority). 1. Preemptive 2. non-preemptive SJF is a priority scheduling where priority is the predicted next CPU burst time. Problem with the priority scheduling is Starvation – low priority processes may never execute

29 Priority Scheduling Process Priority Burst Time P1 2 24 P2 1 3 P3 3 3 The Gantt Chart for the non-preemptive schedule is: 0 3 27 30 Waiting time for P1 = 3; P2 = 0; P3 = 27 Average waiting time: (3+ 0 + 27)/3 = 10 P2 P1 P3

30 Priority Scheduling Process Burst Time Priority Arrival Time P1 3 2 0 P2 2 1 1 P3 1 3 2 The Gantt Chart for the preemptive schedule is: 0 1 2 3 5 6 Waiting time for P1 = 3 – 1 - 0 =2; P2 = 1 – 1 = 0; P3 = 5 – 2 = 3 Average waiting time: (2+0+3)/3 = 1.6 P1 P2 P1 P3

31 Multilevel Queue Ready queue is partitioned into separate queues Each queue has its own scheduling algorithm Scheduling must be done between the queues.

32 Multilevel Queue Scheduling Highest priority Lowest priority SYSTEM PROCESS INTERACTIVE PROCESS INTERACTIVE EDITING PROCESS BATCH PROCESS STUDENT PROCESS

33 Multilevel Feedback Queue A process can move between the various queues Multilevel-feedback-queue scheduler defined by the following parameters: 1. number of queues 2. scheduling g algorithms for each queue 3. method used to determine when to upgrade a process 4. method used to determine when to demote a process 5. method used to determine which queue a process will enter when that process needs service

34 Example of Multilevel Feedback Queue Three queues: 1. Q0 – time quantum 8 milliseconds 2. Q1 – time quantum 16 milliseconds 3. Q2 – FCFS Quantum=8 Quantum=16 FCFS

35 THANK YOU


Download ppt "Topic : Process Management Lecture By: Rupinder Kaur Lecturer IT, SRS Govt. Polytechnic College for Girls,Ludhiana."

Similar presentations


Ads by Google