0% found this document useful (0 votes)
4 views30 pages

UNIT 3 Scheduling

The document discusses various scheduling algorithms in operating systems, including the Banker's Algorithm for resource allocation and safety, as well as multilevel queue and multilevel feedback queue scheduling. It outlines the structures and processes involved in these algorithms, their advantages and disadvantages, and the complexities of multiprocessor scheduling approaches. Additionally, it highlights the differences between asymmetric and symmetric multiprocessing and their respective scheduling methods.

Uploaded by

aadityajoshi2k5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views30 pages

UNIT 3 Scheduling

The document discusses various scheduling algorithms in operating systems, including the Banker's Algorithm for resource allocation and safety, as well as multilevel queue and multilevel feedback queue scheduling. It outlines the structures and processes involved in these algorithms, their advantages and disadvantages, and the complexities of multiprocessor scheduling approaches. Additionally, it highlights the differences between asymmetric and symmetric multiprocessing and their respective scheduling methods.

Uploaded by

aadityajoshi2k5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 30

UNIT-3

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.

Data Structure Definition Example

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.

2) If Request <= Available


i

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:

Available = Available – Requesti


Allocation = Allocation + Request
i i i

Need = Need – Request


i i i
EXAMPLES
OF
BANKER’S ALGORITHM:
Ques: Consider a system that contains five processes P1, P2, P3, P4, P5 and the three resource types A, B and
C. Following are the resources types: A has 10, B has 5 and the resource type C has 7 instances.

Process Allocation Max Available


A B C A B C A B C
P1 0 1 0 7 5 3 3 3 2
P2 2 0 0 3 2 2
P3 3 0 2 9 0 2
P4 2 1 1 4 2 2
P5 0 0 2 5 3 3

Answer the following questions using the banker's algorithm:


1.What is the reference of the need matrix?

2.Determine if the system is safe or not.

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 number of queues.

• The scheduling algorithm for each queue.

• The method used to determine when to upgrade a process to a higher-priority queue.

• The method used to determine when to demote a process to a lower-priority queue.

• 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.

• However multiple processor scheduling is more complex as compared to single processor


scheduling.

• Multiple-processor scheduling is important because it enables a computer system to


perform multiple tasks simultaneously, which can greatly improve overall system
performance and efficiency.

• Multiple-processor scheduling works by dividing tasks among multiple processors in a


computer system, which allows tasks to be processed simultaneously and reduces the
overall time needed to complete them.
Types of Multi Processor Scheduling
Approaches
1.Asymmetric Multiprocessing:

It is used when all the scheduling decisions and I/O processing


are handled by a single processor called the Master Server.
The other processors execute only the user code. This is
simple and reduces the need for data sharing, and this entire
scenario is called Asymmetric Multiprocessing.
Disadvantage:
Performance degradation due to scheduling overheads on a
single CPU and other CPU’s will wait for that single CPU.
Asymmetric Multi Processor Scheduling
2. Symmetric Multiprocessing:

It is used where each processor is self-scheduling. All processes


may be in a common ready queue, or each processor may have its
private queue for ready processes. The scheduling proceeds further
by having the scheduler for each processor examine the ready
queue and select a process to execute.
Symmetric Multi Processor Scheduling
Types of Symmetric Multi Processor Scheduling

1. Symmetrical scheduling with Global Queues

2. Symmetrical scheduling using per CPU Queue or Local Queue

3. Symmetrical scheduling using Hybrid Approach


1. Symmetrical scheduling with Global Queues
Advantages:
1. Good CPU utilization
2. Fair to all processes

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.

You might also like