UNIT 3 Scheduling
UNIT 3 Scheduling
SCHEDULING
RAG(RESOURCE ALLOCATION GRAPH EXAMPLE)
RAG(RESOURCE ALLOCATION GRAPH EXAMPLE)
BANKER’S ALGORITHM
Let ‘n’ be the number of processes in the system and ‘m’ be the number of resource types.
Available[j] = K
It is a single dimensional array that specifies the number It means K instances
Current Available of instances of each resource type currently available. of resource type R1
are currently available.
Max[i][j] = K
It is a two dimensional array that specifies the maximum It means process P1 is allowed to ask for
Max Need number of instances of each resource type that a maximum K instances of resource type
process can request. R1.
Allocation[i][j] = K
It is a two dimensional array that specifies the number of It means K instances of resource type R1
Allocation instances of each resource type that has been allocated have been allocated to the process P1.
to the process.
Need[i][j] = K
It is a two dimensional array that specifies the number of It means process P1 requires K more
Remaining Need instances of each resource type that a process requires instances of resource type R1 for
for execution. execution.
Safety Algorithm
Resource-Request Algorithm
1) If Request <= Need
i i
Goto step (2) ; otherwise, raise an error condition, since the process has exceeded its maximum
claim.
Goto step (3); otherwise, P must wait, since the resources are not available.
i
3) Have the system pretend to have allocated the requested resources to process Pi by modifying the
state as
follows:
3.What will happen if the resource request (1, 0, 0) for process P1 can the system accept this
request immediately?
Multilevel Queue Scheduling
• Another class of scheduling algorithms has been created for situations in which processes are easily classified into different
groups.
• For example, A common division is made between foreground(or interactive) processes and background (or batch)
processes. These two types of processes have different response-time requirements, and so might have different scheduling
needs. In addition, foreground processes may have priority over background processes.
• A multi-level queue scheduling algorithm partitions the ready queue into several separate queues. The processes are
permanently assigned to one queue, generally based on some property of the process, such as memory size, process priority,
or process type. Each queue has its own scheduling algorithm.
• For example, separate queues might be used for foreground and background processes. The foreground queue might be
scheduled by the Round Robin algorithm, while the background queue is scheduled by an FCFS algorithm.
• In addition, there must be scheduling among the queues, which is commonly implemented as fixed-priority preemptive
scheduling. For example, The foreground queue may have absolute priority over the background queue.
Multilevel Queue Scheduling
Multilevel Feedback Queue Scheduling
• In a multilevel queue-scheduling algorithm, processes are permanently assigned to a queue on entry to the system.
Processes do not move between queues. This setup has the advantage of low scheduling overhead, but the disadvantage of
being inflexible.
• Multilevel feedback queue scheduling, however, allows a process to move between queues. The idea is to separate
processes with different CPU-burst characteristics. If a process uses too much CPU time, it will be moved to a lower-priority
queue. Similarly, a process that waits too long in a lower-priority queue may be moved to a higher-priority queue. This form
of aging prevents starvation.
Parameters of Multilevel Feedback Queue Scheduling
• The method used to determine which queue a process will enter when that process needs service.
Multilevel Feedback Queue Scheduling
Advantages
• This is a flexible Scheduling Algorithm
• This scheduling algorithm allows different processes to move between
different queues.
• In this algorithm, A process that waits too long in a lower priority
queue may be moved to a higher priority queue which helps in
preventing starvation.
Disadvantages
• This algorithm is too complex.
• As processes are moving around different queues which leads to the
production of more CPU overheads.
• In order to select the best scheduler this algorithm requires some
other means to select the values
Multi Processor Scheduling
• In multiple-processor scheduling multiple CPU’s are available and hence Load
Sharing becomes possible.
Disadvantages:
3. If all the CPUs are able to access the queue at the same time, then it might be possible that one process is picked
by more than one CPU for execution.
4. Processor affinity (means the user cant choose the CPU according to his/her choice.)
5. Not scalable (contention for the global queue)such that no locking mechanism.
2. Symmetrical scheduling using per CPU Queue or Local
Queue
Advantages:
1. Easy to implement and has no performance degradation.
2. Scalable (no contention due to locking.)
3. Locality(CPU scheduler has to look up its local ready queue)
Disadvantages:
1. Load imbalance
3. Symmetrical scheduling using Hybrid Approach
1. Each CPU has a fair share of
processes to execute in its local
ready queue.
2. Uses local and global queues
both.
3. Load balancing across queues is
feasible.