Sei sulla pagina 1di 5

HYBRID SCHEDULING AND DUAL QUEUE SCHEDULING

Syed Nasir Mehmood Shah Ahmad Kamil Bin Mahmood Alan Oxley
Department of Computer and Department of Computer and Department of Computer and
Information Sciences Information Sciences Information Sciences
Universiti Teknologi PETRONAS, Universiti Teknologi PETRONAS, Universiti Teknologi PETRONAS,
Bandar Seri Iskandar, 31750 Bandar Seri Iskandar, 31750 Bandar Seri Iskandar, 31750
Tronoh, Perak, Malaysia. Tronoh, Perak, Malaysia. Tronoh, Perak, Malaysia.
nasirsyed.utp@gmail.com kamilmh@petronas.com.my alanoxley@petronas.com.my

Abstract- Multiprogramming computer systems execute (Graphical User Interface). Let us briefly mention some of
multiple programs concurrently. An objective of the simulators that are available.
multiprogramming is to optimize resource utilization. Efficient Suranauwarat [4] developed a simulator which produces
resource utilization is achieved by sharing system resources a simulation of various scheduling algorithms for a single
amongst multiple users and system processes. Optimum resource CPU. A user can run this simulator with predefined
sharing depends on the efficient scheduling of competing users scheduling parameters and can also customize parameters
and system processes for the processor, which renders process for a set of processes. The simulator works in two operating
scheduling an important aspect of a multiprogramming operating modes. The first mode is ‘simulation mode’ and the second
system. As the processor is the most important resource, process
one is called ‘practice mode’. In simulation mode, the user
scheduling, which is called CPU scheduling, becomes all the more
important in achieving the above mentioned objectives.
can interact with the simulation during process execution. A
Many algorithms have been developed for the CPU scheduling user can start and stop the simulation whenever he or she
of a modern multiprogramming operating system. Our research likes. A user can also monitor the simulation straight
work involves the design and development of new CPU scheduling through from the beginning until the end. By using the
algorithms (the Hybrid Scheduling Algorithm and the Dual simulator in simulation mode, the user could achieve a
Queue Scheduling Algorithm) with a view to optimization. This better conceptual understanding of the CPU scheduling
work involves a software tool which produces a comprehensive algorithms. In practice mode, the user can predict when and
simulation of a number of CPU scheduling algorithms. The tool’s for how long each process is in a particular state. The user is
results are in the form of scheduling performance metrics. also able to predict why a process is in that state through a
very good graphical user interface. The user is also provided
Keywords- Operating System, CPU Scheduling, Process
Management, Resource Scheduling, Multiprogramming with the facility to check whether his or her answer is
correct or not at any time during practice. One drawback of
this research work is that it is only limited to traditional
I. INTRODUCTION scheduling policies. Another drawback is that it does not
Scheduling is a fundamental function of an operating provide any comparative results of different scheduling
system. It is described in every undergraduate textbook on policies.
operating systems; see for example [1]. The main concept is [5] provides a scheduling simulator named CSCI 152
to share computer resources among a number of processes. CPU Scheduling Algorithm Simulator. This simulator is a
Almost each computer resource is scheduled before use. server-side program that allows the user to interact with it
The CPU is one of the primary computer resources, so its via its web form. It provides a very good graphical web-
scheduling is essential to an operating system’s design. CPU based interface. It gives a comparison of the performance of
scheduling decides which processes execute when there are three scheduling algorithms (the FCFS, RR, and SJF
multiple run-able processes. CPU scheduling is important scheduling algorithms) for the same set of processes. The
because it plays an important role in effective resource limitations of this simulator are that it only works for three
utilization and the overall performance of the system. scheduling algorithms and that the comparative analysis
Scheduling is a branch of the topic of Operational only relates to response times.
Research. In the work described here, we are considering The Tran’s Scheduling Algorithm Simulator [6] supports
how best to schedule multiple jobs for processing by a a number of scheduling algorithms such as FCFS, RR, SJF,
single machine (CPU). It is a relatively easy problem as SRTF and HRR. The time quantum is program coded and
compared to the problem of scheduling multiple jobs for taken as 1 for each set of processes. It lets the user create a
multiple machines. Some idea of the difficulties associated personal set of processes. However, this simulator uses a
with this latter problem can be garnered by studying ‘job simple process model, that is, there is only one CPU burst
shop’ and ‘flow shop’ scheduling problems, see for example per process. The drawback of this simulator is that the
[2, 3]. programmed time quantum is one and this causes a number
There are many existing CPU scheduling algorithm of context switches. This simulator does not produce a
simulators. Some are more user-friendly than others. Some comparative performance analysis of the different CPU
are command-line driven whilst others have a GUI scheduling policies.
_____________________________
978-1-4244-4520-2/09/$25.00 ©2009 IEEE


Each of the above simulators uses a Gantt chart to C. Shortest Remaining Time First Scheduling Algorithm
animate which process is using the CPU at what time. This (SRTF)
approach is fine when the process model is one CPU burst For this algorithm the ready queue is maintained in order
per process. of CPU burst length, with the shortest burst length at the
The authors decided to develop their own scheduling head of the queue. A PCB of a process submitted to the
simulator. A new program was necessary as no system was system has its CPU burst length compared with the
available to offer the desired functionality. The resultant remaining time of the PCB being executed. If the new
program needed to be an efficient, pictorial and user- process requires less time than that remaining of the ‘active’
friendly simulation to depict a multiprogramming process then preemption occurs and it becomes the new
environment on a PC-based platform. There existed a strong PCB’s turn for execution, otherwise it is linked to the queue
need for such a system which would enable a PC-based user in accordance with its CPU burst length. The algorithm
to analyze a multiprogramming operating system dispatches processes from the head of the ready queue for
environment, for the purpose of either analyzing the design execution by the CPU. When a process has completed its
of a CPU scheduling system or studying the science of task it terminates and is deleted from the system. The next
process scheduling. The system described here has been process is then dispatched from the head of the ready queue.
designed with a view to fill the gap, offering a modest
simulation of a PC-based multiprogramming environment. D. Round Robin Scheduling Algorithm (RR)
It includes a graphical animation of the algorithm. The For this algorithm the ready queue is maintained as a
simulator is unique in a number of respects. FIFO queue. A PCB of a process submitted to the system is
It should be emphasized that there is a valuable ‘spin- linked to the tail of the queue. The algorithm dispatches
off’ to this part of our work in that the simulator can be used processes from the head of the ready queue for
in the classroom. Studies have shown that computer science execution by the CPU. Processes being executed are
algorithm simulations, particularly animated ones, have the preempted on expiry of a time quantum, which is a system-
potential to enhance understanding and learning, see for defined variable. A preempted process’s PCB is linked to the
example [7]. However, care must be taken to integrate a tail of the ready queue. When a process has completed its
simulator into the curriculum otherwise it may have little task, i.e. before the expiry of the time quantum, it terminates
effect [8]. and is deleted from the system. The next process is then
The remainder of this paper is organized as follows: dispatched from the head of the ready queue.
Section 2 discusses scheduling algorithms. Section 3
presents evaluation of results and discussion and section 4 E. Priority Scheduling Algorithm
concludes the paper. For this algorithm the ready queue is maintained in the
order of system-defined priorities. A PCB of a process
II. SCHEDULING ALGORITHMS submitted to the system is linked to the last PCB in the
To begin with we will briefly describe five commonly queue having the same or a higher priority. The algorithm
occurring algorithms [1, 9, 10]. This will be followed by dispatches processes from the head of the ready queue
detailed descriptions of the two new CPU scheduling for execution by the CPU. When a process has completed
algorithms. its task it terminates and is deleted from the system. The
next process is then dispatched from the head of the ready
A. First Come First Served Scheduling Algorithm (FCFS) queue.
FCFS is the simplest scheduling algorithm. For this
algorithm the ready queue is maintained as a FIFO queue. A F. Hybrid Scheduling Algorithm (H)
PCB (Process Control Block) of a process submitted to the For this algorithm the ready queue is maintained in order
system is linked to the tail of the queue. The algorithm of CPU burst length, with the shortest burst length at the
dispatches processes from the head of the ready queue head of the queue. Two numbers are maintained. The first
for execution by the CPU. When a process has completed number, tlarge , represents the burst length of the largest PCB
its task it terminates and is deleted from the system. The in the queue while the second one, texec , represents a
next process is then dispatched from the head of the ready running total of the execution time of all processes (since a
queue. reset was made). A PCB of a process submitted to the
system is linked to the queue in accordance with its CPU
B. Shortest Job First Scheduling Algorithm (SJF) burst length.
For this algorithm the ready queue is maintained in order The algorithm dispatches processes from the head of
of CPU burst length, with the shortest burst length at the the ready queue for execution by the CPU. Processes
head of the queue. A PCB of a process submitted to the being executed are preempted on expiry of a time quantum,
system is linked to the queue in accordance with its CPU which is a system-defined variable. Following preemption,
burst length. The algorithm dispatches processes from the texec is updated as follows:
head of the ready queue for execution by the CPU. When a
process has completed its task it terminates and is deleted texec = texec + quantum
from the system. The next process is then dispatched from
the head of the ready queue.


If t exec < t l arg e then the preempted process’s
PCB is linked to the tail of the execution queue. The next
process is then dispatched from the head of the execution
queue.
t exec≥t l arg e
If then the PCB with the largest
CPU burst length is given a turn for execution. Upon
preemption, all PCBs in the waiting queue are moved to the
execution queue, leaving the waiting queue empty. The
execution queue is then sorted on the basis of SJF. The
value of tlarge is reset to the burst length of the largest PCB
and texec is reset to 0. The next process is then dispatched
from the head of the execution queue.
Figure 1. Process State Diagram of H. When a process has completed its task it terminates and
is deleted from the system. texec is updated as follows:
The numbers are then compared. texec = texec + time to complete
If t exec < t l arg e then the preempted process’s
PCB is linked to the tail of the ready queue. The next
process is then dispatched from the head of the ready queue.
t exec≥t l arg e
If then the PCB with the largest
CPU burst length is given a turn for execution. Upon
preemption, the ready queue is sorted on the basis of SJF.
The value of tlarge is reset to the burst length of the largest
PCB, which is lying at the tail of the queue, and texec is reset
to 0. The next process is then dispatched from the head of
the ready queue.
When a process has completed its task it terminates and
is deleted from the system. texec is updated as follows:
texec = texec + time to complete
The numbers are then compared and the actions taken
are the same as those for a preempted process.
G. Dual Queue Scheduling Algorithm (DQ) Figure 2. Process State Diagram of DQ.
For this algorithm the ready queue comprises two
queues – the waiting queue and the execution queue. The The numbers are then compared and the actions taken
waiting queue is maintained as a FIFO queue. A PCB of a are the same as those for a preempted process.
process submitted to the system is linked to the tail of the
III. EVALUATION OF RESULTS AND DISCUSSION
waiting queue. Whenever the execution queue is empty, all
PCBs in the waiting queue are moved to the execution queue, The simulator has been used to carry out
leaving the waiting queue empty. The execution queue is extensive experimentation using the Windows Vista
maintained in order of CPU burst length, with the shortest operating system on an Intel Core2 Duo. The
burst length at the head of the queue. Two numbers are simulations of the algorithms have generated useful data
maintained. The first number, tlarge , represents the burst that has been analyzed.
length of the largest PCB in the ready queue (waiting queue To check the performance of the proposed algorithms,
and execution queue combined) while the second one, texec , i.e. H and DQ, we took twenty process sets, each with
represents a running total of the execution time of all different characteristics, and ran these through the
processes (since a reset was made). The algorithm simulator. Each process set consists of ten processes. Each
dispatches processes from the head of the execution process is specified by its CPU burst length, arrival time
queue for execution by the CPU. Processes being executed and priority number. Each process set has been given a
are preempted on expiry of a time quantum, which is a time quantum for simulation.
system-defined variable. Following preemption, texec is Performance metrics for the CPU scheduling
updated as follows: algorithms are based on three factors - Average Waiting
Time, Average Turn Around Time, and Average Response
texec = texec + quantum Time. Table I shows the average time, for each process set,
for each performance factor and algorithm combination.
The numbers are then compared. Performance Factors


Average resulting waiting/turnaround times experienced by the
Average Average individual processes will be in accordance with their relative
Scheduling Turn
Waiting Response positions in the batch. For a batch processed with SJF the
Algorithm around
Times Times resulting waiting/turnaround times will be such that short
Times
FCFS 11224.00 13604.90 11224.02 jobs will be executed earlier than long jobs. Short jobs
experience shorter waiting times with SJF in comparison with
SJF 6544.87 8925.70 6544.84 FCFS. Medium burst length processes experience almost
SRTF 4937.59 4653.89 3170.69 equal waiting times in both algorithms. Long processes,
Priority however, result in shorter waiting times with FCFS when
8657.02 11182.80 8803.51
compared to SJF. Overall, the average waiting time of the batch
Priority(P) 7577.11 9957.95 6860.31 has shortened in comparison with the FCFS.
RR 6186.28 8443.62 2553.90 C. SRTF
H 3136.23 5517.06 2614.49 The jobs are submitted to the system and executed on the
DQ 4744.32 7125.15 1937.31 basis of SJF. It is a preemptive variant of SJF. It produces
more optimized results as compared to FCFS and SJF.
TABLE I EXPERIMENTAL RESULTS
D. RR
Below is graph derived from Table I, and this is followed All processes get equitable response time and share of the
by a discussion. Fig. 3 shows graphs of the Average Waiting processor’s time, making this algorithm attractive for time
Times, Average Turnaround Times, and Average Response sharing systems. Shorter processes complete before the
Times, respectively. expiry of the time quantum, so such processes, if present in
the batch, are completed earlier. Medium burst length
processes consume a few time slices before completion.
Long processes take a greater number of time slices for
completion resulting in longer completion time.
The relationship between the time slice and performance
is nonlinear. Too short a time slice may result in
significant overhead due to the frequent timer interrupts
and context switches. On the other hand, too long a time slice
reduces the preemption overhead but increases response time.
E. Preemptive Priority Scheduling Algorithm
It is a preemptive version of priority scheduling. The
processes are prioritized in accordance with their
operational significance. It produces optimized results as
compared to Priority scheduling and FCFS for most of
the cases.
F. Hybrid Scheduling Algorithm(H)
Figure 3. Graph showing the comparison of all performance factors
H is based on RR and SJF. Fig. 3 shows that average
waiting times computed for H is optimum. It produces the
A. FCFS least average waiting time as compared to the other CPU
Results obtained by simulation of FCFS have confirmed scheduling policies. Fig. 3 also shows that average
that the execution of FCFS produces smaller computational turnaround time calculated for H is greater than the
overheads. It gives poor performance, lower throughput and computed average turnaround time by SRTF but less than
longer average waiting times. The relationship between the computed average turnaround times for all other CPU
average CPU burst length and average waiting time is non- scheduling policies. Furthermore, Fig. 3 shows that the
linear. average response time calculated for H is slightly greater
than the computed values for RR and DQ but less than the
B. SJF computed average response times for other CPU scheduling
SJF is an optimal scheduling discipline in terms of policies.
minimizing the average waiting time of a given workload. G. DQ
However, preferred treatment of short processes in SJF tends
DQ is an extended form of H. Fig. 3 shows that the
to result in increased waiting times for long processes. Thus, if
average waiting time computed for DQ is slightly greater
there is a continuous inflow of short processes in the system
than the computed value for H. However, it shows the least
there is a possibility that long processes may get stranded in
average waiting time as compared to the other CPU
the ready queue forever. Let us now compare FCFS with
scheduling policies. Fig. 3 also shows that the average
SJF. In cases where a batch is processed with FCFS, the


turnaround time for DQ is greater than the computed Hence H works well from a system perspective. We can
average turnaround times for SRTF and H but less than the say that H is a scheduling policy from the system point of
computed average turnaround times for all other CPU view; it satisfies the system requirements (i.e. minimum
scheduling policies. Furthermore, Fig. 3 shows that the Average Waiting Time and minimum Turn Around Time).
average response time calculated for DQ is optimum. It DQ works excellently from a system perspective. We can
produces the least average response time as compared to all say that DQ is a scheduling policy from the user’s point of
other CPU scheduling policies. view because it meets the user requirements (i.e. minimum
The experimental results are according to the Average Response Time). These results are extremely useful
established facts and principles of the science of process for the designing and development of modern operating systems.
scheduling. Performance metrics have been derived from Let us now consider the new simulator. This has been
the experimental results. They are presented in Table II. put through extensive experimentation. Various possible
input patterns have been experimented with, from the above-
IV. CONCLUSIONS mentioned CPU scheduling algorithms. The overall
Results have shown that the execution of FCFS response of the system has been monitored accordingly.
produces smaller computational overheads because of its Behaviour of the system and the experimentation results,
simplicity, but it gives poor performance, lower throughput and thereafter, has been in conformity with the established facts and
longer Average Waiting Times. SJF is an optimal scheduling principles of the science of process scheduling and we believe
discipline in terms of minimizing the average waiting time of that the simulator is a valuable contribution to the
a given workload. However, the preferred treatment of short understanding of modern operating systems.
processes in SJF tends to result in increased waiting times for
long processes in comparison with FCFS. Thus, there is a REFERENCES
possibility that long processes may get stuck in the ready [1] A. Silberschatz, P. B. Galvin, G. Gagne, “Operating System
queue because of the continuous arrival of shorter processes in Concepts”, 7th ed., John Wiley & Sons, 2005.
the queue. RR achieves fair sharing of the CPU. Short [2] Jacek Blazewicz, Wolfgang Domschke, Erwin Pesch, “The job shop
scheduling problem: Conventional and new solution
processes execute within a single time quantum and thus techniques”,European Journal of Operational Research, Volume 93,
exhibit good response time. It tends to subject long processes to Issue 1, 23 August 1996, pp.1-33.
relatively longer turn around and waiting times. In the case [3] Chandrasekharan Rajendran, Oliver Holthaus, “A comparative study
of priority-based scheduling there is a possibility that low- of dispatching rules in dynamic flow shops and job shops”, European
priority processes will, in effect, be locked out by the higher Journal of Operational Research Vol. 116, No. 1 (1999), pp. 156-170.
priority ones. In other words, completion of a process within a [4] Sukanya Suranauwarat, “A CPU Scheduling Algorithm Simulator”,
finite time of its creation cannot be guaranteed with this 37th ASEE/IEEE Frontiers in Education Conference, October 2007,
pp. F2H19-F2H24.
scheduling policy. In RR there is fairness across the jobs, i.e.
the jobs get equal time. However, upon completion of the [5] http://www.capricorn.org/~akira/cgi-bin/scheduler/index.html.
time quantum, the PCB is linked to the tail of the ready [6] http://www.utdallas.edu/~ilyen/animation/cpu/program/prog.html
queue and waits in the ready queue until it again gets the [7] Andrea W. Lawrence, Albert Badre, John Stasko, "Empirically
Evaluating the Use of Animations to Teach Algorithms", Proceedings
time quantum (after a complete circle). The processes with of the 1994 IEEE Symposium on Visual Languages, 1994, pp. 48-54.
very small burst lengths also wait for a long time in the
[8] John Stasko, Albert Badre , Clayton Lewis, "Do Algorithm
ready queue. H provides optimized results for turn around Animations Assist Learning? An Empirical Study and Analysis",
time, response time and waiting time. There is no starvation Proceedings of the SIGCHI conference on Human factors in
for any jobs when using the H. There is a little overhead computing systems, 1993, pp. 61-66.
due to the sorting involved with H. In order to avoid the [9] Milan Milenkovic, “Operating System Concepts and Design”, Second
overhead of sorting, DQ was introduced. DQ gives Edition McGraw Hill International, 1992.
optimized results with minimum overhead and best response [10] Leland L. Beck, “System Software”, 3rd Ed., Addison Wesley, 1997
times for all nature of process sets. And again, there is no
starvation for any process when using DQ.
FCFS RR SJF SRTF Priority Priority (P) H DQ
Selection
max[w] constant min[s] min[s-e] min[p] min[p] SJF SJF
Function
Decision non pre- non pre- non
pre-emptive RR RR
Mode pre-emptive emptive pre-emptive emptive pre-emptive
low for
Through-put low high high low average high high
small quantum
Response less for
high less less average average less least
Time short processes
Turn Around less for less for less/ slightly
high least average average less
Time short processes short processes higher than SRTF
Waiting less for
high less less average average least less
Time short processes
Overhead minimal low can be high can be high can be high can be high can be high low
Starvation no no possible possible possible possible no no
Where w = waiting time e = execution time p= priority number
s = total service time required by the process including execution time(e)
TABLE II PERFORMANCE METRICS



Potrebbero piacerti anche