Priority Scheduling
- The basic idea is straightforward: each process is assigned a
priority, and priority is allowed to run. Equal-Priority processes are
scheduled in FCFS order. The shortest-Job-First (SJF) algorithm is a special
case of general priority scheduling algorithm.
- An SJF algorithm is simply a priority algorithm where the
priority is the inverse of the (predicted) next CPU burst. That is, the
longer the CPU burst, the lower the priority and vice versa.
- Priority can be defined either internally or externally. Internally
defined priorities use some measurable quantities or qualities to compute
priority of a process.
- Examples of Internal priorities are
- Time limits.
- Memory requirements.
- File requirements,
- for example, number of open files.
- CPU Vs I/O requirements.
- Externally defined priorities are set by criteria that are
external to operating system such as
- The importance of process.
- Type or amount of funds being paid for computer use.
- The department sponsoring the work.
- Politics.
- Priority scheduling can be either preemptive or non preemptive
- A preemptive priority algorithm will preemptive the CPU if the
priority of the newly arrival process is higher than the priority of the
currently running process.
- A non-preemptive priority algorithm will simply put the new
process at the head of the ready queue.
- A major problem with priority scheduling is indefinite blocking
or starvation. A solution to the problem of indefinite blockage of the
low-priority process is aging. Aging is a technique of gradually
increasing the priority of processes that wait in the system for a long
period of time.
|
|
Multilevel Queue Scheduling
- A multilevel queue scheduling algorithm partitions the ready
queue in several separate queues, for instance
- In a multilevel queue scheduling processes are permanently
assigned to one queues.
- The processes are permanently assigned to one another, based on
some property of the process, such as
- Memory size
- Process priority
- Process type
- Algorithm choose the process from the occupied queue that has
the highest priority, and run that process either
- Preemptive or
- Non-preemptively
- Each queue has its own scheduling algorithm or policy.
Possibility
I
If each queue has absolute priority over lower-priority
queues then no process in the queue could run unless the queue for the
highest-priority processes were all empty.
For example, in the above figure no process in the batch queue
could run unless the queues for system processes, interactive processes, and
interactive editing processes will all empty.
Possibility
II
If there is a time slice between the queues then each
queue gets a certain amount of CPU times, which it can then schedule among
the processes in its queue. For instance;
80% of the CPU time to foreground queue using RR.
20% of the CPU time to background queue using FCFS.
Since processes do not move between queue so, this policy has
the advantage of low scheduling overhead, but it is inflexible.
|
Multilevel Feedback Queue Scheduling
- Multilevel feedback queue-scheduling algorithm allows a process
to move between queues. It uses many ready queues and associate a different
priority with each queue.
- The Algorithm chooses to process with highest priority from the
occupied queue and run that process either preemptively or unpreemptively.
- If
the process uses too much CPU time it will moved to a lower-priority queue.
Similarly, a process that wait too long in the lower-priority queue may be
moved to a higher-priority queue may be moved to a highest-priority queue.
- Note that this form of aging prevents starvation.
Example:
- A process entering the ready queue is placed in queue 0.
- If it does not finish within 8 milliseconds time, it is moved to
the tail of queue 1.
- If it does not complete, it is preempted and placed into queue
2.
- Processes in queue 2 run on a FCFS basis, only when queue 2 run
on a FCFS basis, only when queue 0 and queue 1 are empty.`
|
No comments:
Post a Comment