Documente Academic
Documente Profesional
Documente Cultură
1 : Resource Management
Part2 :Processor Management
Learning Outcomes
3.1.1 Understand Processor Management 3.1.2 Various type of scheduling processes 3.1.3 Scheduling Algorithms First in first out (FIFO) Shortest Job First (Nonpreemptive SJF) Shortest Remaining Time (Preemptive SJF) Round Robin Scheduling Priority
Processor Management
To know how Processor Manager allocates a single CPU to execute the jobs / processes from those user. Task of Processor Manager : Decide i. How to allocate the CPU ii. Monitor whether it s executing or waiting a process . iii.Control job entry to ensure balanced use of resources
Process
Process is a program in execution When process execute it changes state State represent process s current activity Each process may be in one of the following state, which are :
New : the process is being created Running : instruction are being executed Waiting : the process is waiting for some event to occur (reception of signal) Ready : the process is waiting to be assigned to a processor Terminated : the process has finished execution
Process
Waiting queue is place for not executing process. Ready queue is contains all the processes that are ready to execute and waiting for the CPU. Each process is represent by PCB (Process Control Block)
Scheduling Concept
The objective of Multiprogramming is to have some process running at all times, - to maximize CPU utilization Objective of Time-Sharing is to switch the CPU among processes so frequently that user can interact with each program while it is running. A uniprocessor/ single user system can have only one running process. If more processes exist, the rest must wait until the CPU is free and can be rescheduled.
Process Scheduling
Therefore process scheduling is need for schedule processes on your system Why to schedule ? To decide which process to run first if there have more than one process is run able. Scheduler is part of O/S which make this decision.
Schematic of scheduling
Preempted request Arriving requests Scheduled request
CPU
Completed request Data flow Control Flow
Scheduler
Pending requests
Figure above is shows movement of requests in the system All requests waiting to be executed are kept in a list of pending requests. Whenever scheduling is to be performed, the scheduler examines the pending request and select one for executing.
This request is handed over to the CPU. A request leaves the CPU when it completes or when it is preempted by the scheduler. In which case, it is put back into the list of pending request In either situation, scheduler performs scheduling to select next request to be executed.
Cont..
Preemptive
Interrupts the processing of a job and transfer the CPU to another job. Strategy of allowing process that are logically run able to be suspended. It is widely used in time-sharing environments
Nonpreemtive
Always processes a scheduled request to completion Since only one request is under processing by the CPU at any time, it is not necessary to maintain the distinction between long, medium and short term scheduling Example of scheduling are FCFS and SJF scheduling
Scheduling Creteria
1. CPU utilization (Penggunaan CPU) - keep the CPU as busy as possible 2. Throughput(Daya Pemprosesan) number of processes that complete their execution per time unit 3. Turnaround time (Masa pusingan) amount of time to execute a particular process 4. Waiting time( Masa menunggu) amount of time a process has been waiting in the ready queue 5. Response time(Masa tindakbalas) amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment)
Optimization Criteria
Max;
CPU utilization throughput
Min;
turnaround time waiting time response time
Example : FCFS
Process P1 P2 P3 Burst Time (ms) 24 3 3
Waiting time for P1 = 0ms; P2 = 24ms; P3 = 27ms Average waiting time: (0 + 24 + 27)/3 = 17ms
Exercise 1: FCFS
What will happened if the processes arrive in the order P2 , P3 , P1
i. Draw a gantt chart ii. Calculate average waiting time
P1 P2 P3 P4
6 8 7 3
0 0 0 0
P4 0 1
P1 9
P3
P2 16 24
P1 P2 P3 P4
7 4 1 4
0 2 4 5
P3 8
P2 12
P4 16
1. 2. 3. 4.
P1 = 0 P2 = 8 2 = 6 P3 = 7 4 = 3 P4 = 12 5 = 7
Example 1: SRTF
Process Burst Time Arrival Time
P1 P2
10 2
0 2
P1 0 2
P2 4
P1 12
Exercise 1: SRTF
Exercise 2 : SRTF
Process Burst Time Arrival Time
P1 P2 P3 P4
24 3 3 1
0 1 2 3
i) Draw a gantt chart ii) Calculate are waiting time for each process iii) Calculate average waiting time
P1 P2 P3
24 3 3
P1 0
P2 4
P3 7
P1 10
P1 14
P1 18
P1 22
P1 26 30
Exercise 1: RR Scheduling
P1 P2 P3 P4 P5
10 1 2 1 5
3 1 4 5 2
P2 0 1
P5
P1
19