Computers & Operations Research 32 (2005) 229 – 238
www.elsevier.com/locate/dsw
Priority queuing in an operating system Ali Derbala∗ Faculty of Science, Mathematics Department, University of Blida, BP 270, Route de Soumaa, Blida, Algeria
Abstract The analysis of a preemptive priority queuing system with K(¿ 2) classes of jobs is undertaken. The system consists of a single processor representing a model of discrete dynamic scheduling problems associated with Mk =Gk =1=∞ endogenous priority queues. The processor schedules jobs which arrive according to a Markov arrival process. The process of service is arbitrary. With each job are associated particular endogenous dynamic priorities, called scheduling by “mean bounded priorities with arrival pattern” (MBPAP). The main goal is, for the case of an arrival pattern of jobs, to present an original scheduling strategy, to derive the waiting time wk (t) and to discuss the implementation of the priorities. This queuing system is investigated. ? 2003 Elsevier Ltd. All rights reserved. MSC: 60 K25; 60 K30; 68 M20; 90 B36 Keywords: Priority queuing; Endogenous priority; Multi-programmed system; MBPAP; Stochastic scheduling
1. Introduction Our motivation for studying these priorities is to determine the expected response times for some forms of deadline schedulers under heavy load conditions. Schedulers such as those designed by Haro and Proust [1] have been shown to operate in a hyperbolic fashion. The arrival process of jobs of the kth priority class, k = 1; 2; : : : ; m to a single processor is a homogenous Poisson process with rate k . A job from class k is called k-job. Service times of k-jobs are independent and identical arbitrarily distributed random variables with a distribution function Fsk (:). The kth priority class has a non-preemptive priority over the ith priority class if k ¿ i. Within each class of k-jobs, a preemptive priority queue is considered. Jobs arrive at the workshop at the instant rki according to a process independent of the service times. We will consider a discrete time system. ∗
Tel./fax: +1-213-25-43-36-42. E-mail address:
[email protected] (A. Derbala).
0305-0548/$ - see front matter ? 2003 Elsevier Ltd. All rights reserved. doi:10.1016/S0305-0548(03)00214-4
230
A. Derbala / Computers & Operations Research 32 (2005) 229 – 238
Each k-job “i” that enters the waiting line for service is labeled with a priority index deFned by pki (t) =
Mki tkiw (t) + mik tkip (t) t − rki
(1)
for all t; t discrete time decision from the instant rki +1 and where (mik ; Mki ) is a couple of non-negative real values. To be well deFned, the priority at the instant rki , pki (rki ), is chosen to be a real value from the interval [mik ; Mki ]. tkiw (t) and tkip (t) are, respectively, the waiting time in the queue and the total service time up to time t; t ∈ N. Scheduling according to Formula (1) is called “mean bounded priorities with arrival pattern” for short MBPAP. Actually, a priority means an urgency number allocated to each job. This priority is the mean of bounds mik and Mki weighted by the waiting time in the queue and the total service time up to time t. The longer a job waits, the higher would be the chance to be serviced by the processor. The priority of the job, which depends on the time and the service time, is bounded. The job is to be selected with the highest priority among the waiting ones; in a case of a tie, the FIFO rule is employed to break it. Haro and Proust [1] implemented these priorities in the “kernel of an operating system”. They have shown that the choice of the bounds allows to derive some of the known strategies and proved that this priority makes the schedule “asymptotically fair” and its implementation still maintains this property. They have given some eIcient programming hints of the associated algorithm and introduced an adaptation to obtain a fair scheduling. Process and Job are synonymous. In static priority disciplines, the priority of a job is an unchangeable and inherent quality which characterizes the class containing the job. The priorities diKer from each other by the existing relations among and within the classes. The scientiFc and technical community has been very active in the development of innovative disciplines to schedule the allocation and in the use of a shared resource among various requesting jobs with no prior information about service requirements. The decision of selecting the next job for service may be made exogenously, that is, it may depend only upon the knowledge of the priority class containing the job. However, it can be made endogenously, that is the decision may be based solely or partially on other considerations related to the existing state of the system, such as the type of the just serviced job or the waiting time of the present jobs [2], The processes within a computing system do not obviously be carried out as an isolation part, but they must co-operate to achieve the desired objective of the user jobs. Moreover, they compete with the use of the limited resources such as processors, memory and Fles. Both cooperative and competitive aspects imply the need for some ways of communication between processes. The term “scheduling” is understood to cover the questions when to introduce new jobs into the system and which order is employed to indicate the time where jobs are serviced. These subjects are related to resource allocation. The decision on scheduling and resource allocations are so closely related that it is often sensible to point out the responsibility for both in hands of a single system process. This process is commonly called the scheduler. Its basic tasks are: the introduction of new processes, the assignment of priorities to processes and the implementation of resource allocation policies. In addition, it chooses the moment to start an execution and prevents the access for interactive user if the number of connected users is expecting a worst response time. Its purpose is to ensure a fair work which infers a good service for each user. The diKerent results of priority queuing are well covered in the literature [3–16].
A. Derbala / Computers & Operations Research 32 (2005) 229 – 238
231
We would like to report the queuing applied to an endogenous priority; similar studies on other cases have been already enterprised [17–20]. More interests are in the books [2,21–23] which provide a synthesis of most of the results. For an arrival pattern of jobs, our purpose is to provide: (1) An original scheduling strategy of jobs on a single-processor multi-programmed operating system. (2) To derive, for a k-job, the waiting time wk (t). (3) To brieMy discuss the implementation of these priorities. 2. The MBPAP model As far as we know the endogenous priority disciplines have been slightly tackled. Despite the difFculty of their analysis, they are very important practically. In most job-shop scheduling or computer operations, one would like to implement an endogenous priority discipline in which the priority of a job increases as a function of the waiting time, so that the longer a job waits, the higher would be the probability to be serviced by the processor. MBPAP is a work conserving strategy. The processor works as long as there are jobs still waiting for service. The strategies or the sequences of decisions require the service time of the job which is in general unknown. Its estimation involves the knowledge of the system history in order to predict the nearest future. For all t and for all k-job i, the addition of tkiw (t) and tkip (t) is equal to t − rki . Formula (1) can be written as pki (t)
=
Mki
−
ik
tkip (t) t − rki
(2)
for all t; t ¿ rki + 1, where ik is Mki − mik . It is supposed that Mki = Mkj = Mk
and
mik = mkj = mk ;
∀i = 1; : : : ; nk (t)
and
∀j = 1; : : : ; nk (t)
nk (t) is the size of the class k at the time t. tkip (t) will be denoted simply as tki (t). The MBPAP then becomes t i (t) ∀i = 1; : : : ; nk (t); ∀t ¿ rki + 1; pki (t) = Mk − k k i t − rk
(3)
where k is Mk − mk and pki (rki ) is a real value from the interval [mk ; Mk ]. A job is said to be waiting or “ready” to be carried out if all the resources of the system are available except the processor. A job is said to be “running” if it is serviced by the processor. A job is “blocked” if it is waiting for an other resource than the processor, like a printer, a drum, etc. In a real computerized system, the possible states that a job can reach as well as the associated events are illustrated in Fig. 1. An interpretation of the states of the jobs is given below. A job: • enters the system (denoted arrival, direct-edge (a)), • is queued into the ready queue and hence, it is said to be ready, that is the direct-edge (r),
232
A. Derbala / Computers & Operations Research 32 (2005) 229 – 238
Fig. 1. The queuing system.
• • • • • •
is selected to run or to process (edge p), consumes all its quantum and returns to the ready queue (edge s), requires input/output (edge I/O), is queued into the blocked queue, it cannot be immediately serviced (edge b), is decongested. The requested service for the blocked process begins (edge d), departures or exits. It abandons the system (edge e).
A processor (CPU): • enters the idle state (edge i). It cannot carry any job, • exits the idle state (edge w). It is going to carry out a job, • the Fle system is ready. The processor is waiting for a message (edge y). The MBPAP can be described as a mean of input/output oriented, CPU oriented and balanced scheduling scheme. The scheduler attempts to favor the jobs that respectively make an intensive use of input/output. They are those that normally require an operation before their processor quantum is assumed and those are making an intense use of the CPU according to their requirements. If a continuous stream of arriving jobs exists then, at any moment of the current load execution there will be a great number of jobs which will saturate the processor. Then the jobs will be blocked, leaving the ready queue and permitting the delayed jobs to be accessed by the processor. For the upcoming discussion, k-job i are assumed, within the system, either to be waiting (ready) or serviced (running).
A. Derbala / Computers & Operations Research 32 (2005) 229 – 238
233
3. Analysis An exact analysis is possible only for the very simple system models and computation graphs; yet it is less attracted in the case of a time dependent priority [21]. The desired performance of a queuing system that serves various classes of jobs is often expressed by the relative waiting times of the classes. The analysis of the job priority is obviously more diIcult, as the description of the state needs to include information about each class, and is therefore multidimensional. The busy period probabilities would be diIcult to investigate because of the multidimensional nature of the process. For each k-job, our development derives an expression for the expected waiting time. Formally, let, rk be the arrival time of a k-job and pk (t) its priority function at time t given by the formula pk (t) = Mk − (Mk − mk )
tk (t) tk (t) = Mk − k ; t − rk t − rk
t ¿ rk ; k = 1; 2; : : : ; m;
(4)
where k is Mk − mk , and tk (t) is the total service time up to time t. 3.1. Formulation of the expected waiting times Many analyses of a steady-state queuing system were shown to depend on the special properties of the Poisson arrival process and exponentially distributed processing-times to construct a system of diKerential-diKerence equations relating system states with time. However, the resulting systems of equations were often prohibitively diIcult. Hence, we use an alternative approach. Let us consider the behavior of a queue that forms in front of a single processor servicing facility. Jobs will be assumed to make demands for service at a random time and the distribution of demands is known. The exact instant at which a demand will be made is unpredictable. If job arrives during a busy period of the processing, it is joining a queue. Demands are satisFed in the order of a particular priority. The kth priority class has a non-preemptive priority over the ith if k ¿ i. A diKerent priority function is associated with each priority class. Let k be the portion of time during the processor which is busy waiting k-jobs, k = k E(Sk );
k = 1; 2; : : : ; m:
(5)
A necessary and suIcient condition for the service system to reach the steady state is =
m
i ¡ 1:
(6)
i=1
Let S be the service time of a random job. We have Fs (s) =
m
i FSi (s)= ;
(7)
i=1
where = 1 + 2 + · · · + m . Let us consider an imaginary situation where our processor selects a job for servicing according to the FIFO rule disregarding the priority classes. In this regime, the expected waiting time
234
A. Derbala / Computers & Operations Research 32 (2005) 229 – 238
(the time elapsed between the moments of arrival and admittance for service) of a k-job, E(WF ), equals that of job in an M/G/1 model with an arrival rate , and a service time distributed as S, and mathematically written in the Khinchine–Pollaczek formula, 2
E(WF ) = E(S )=(2(1 − )) =
m
i E(Si2 )=(2(1 − )):
(8)
i=1
The waiting time of a k-job in a system working under dynamic priority discipline diKers from that in a system under the FIFO discipline for two reasons: (i) A newly arrived k-job may proceed before i-job (i ¡ k) which is admitted for service after it. (ii) i-jobs which arrive during the waiting time of a k-job (i ¿ k) may be “ahead” of it. Let E(Vij ) be the expected time, after the i-job arrives, during which a newly arrived j-job is admitted for service ahead of the i-job, j ¿ i. That means that the new j-job has greater priority than that of the i-job. The expected time required, for the waiting i-jobs present in the system at the moment of a k-job arrival (i ¡ k) and admitted for service after it (the new k-job has a lesser priority than that of the i-job), is E(Si )( i E(Vik )) = i E(Vik ):
(9)
The expected time required for waiting i-jobs, arriving during the waiting time of a k-job (i ¿ k) and admitted ahead of it, is E(Si )( i E(Vki )) = i E(Vki ):
(10)
Hence, the expected waiting time of a k-job, E(Wk ), in a dynamic priority regime equals that of the FIFO discipline, (8), minus (9) for i ¡ k, and plus, (10) for i ¿ k, thus E(Wk ) = E(WF ) −
k −1
i E(Vik )) +
i=1
m
i E(Vki ):
(11)
i=k+1
Now it remains to express E(Vki ); i ¿ k by the known parameters of the system. 3.2. Calculations of E(Vij ); i ¡ j We remind that job i is “ready” to be queued in a ready queue and therefore waiting for service. Job i is “running” if it is serviced by the processor. If job i is ready or waiting then pki (t) is increasing in a concave sense. Its plot versus time gives an hyperbolic graph with asymptotes t = 0 and t = Mi . If job i is “running” or serviced then pki (t) is decreasing in a convex sense. Two priorities may intersect either more than once or not at all. Without loss of generality, we set the arrival moment of a j-job as t = 0. We denote by (−tij ) the arrival moment of an i-job, i ¡ j, whose priority is equal to the priority of the j-job at the moment t = tij (Two cases are possible as depicted in Figs. 2 and 3). We suppose that k ¿ i ¿ j. kj is the moment at which the priority function of a k-job, k ¡ j, which arrived at t = −kj is equal to that of a j-job which arrived at t = 0. An i-job (i ¡ j) which arrived at time t; t ¿ − tij , is in the queue at time t = 0.
A. Derbala / Computers & Operations Research 32 (2005) 229 – 238
235
Fig. 2. Diagram of behavior of the priorities.
Fig. 3. Intersection of priority functions.
By shifting the scale, we can suppose that tij is zero. An i-job (i ¡ j) which arrives at time t; t ¿ − tij , and is in the queue at time Iij , is carried out after our j-job (see Fig. 3). Moreover an i-job which arrives at t = −kj , kj ¿ tij , is admitted for service if and only if its waiting time, Wi , exceeds kj + KJij (see Fig. 2). Thus we have tij ∞ P(Wi ¿ ) d + P(Wi ¿ + tij ) d; (12) E(Vij ) = =0
E(Vij ) = E(Wi ) −
=tij
=tij
P( 6 Wi 6 + tij ) d;
(13)
236
A. Derbala / Computers & Operations Research 32 (2005) 229 – 238
E(Vik ) = E(Wi ) −
∞
=tik
E(Vki ) = E(Wk ) −
∞
=tki
P( 6 Wi 6 + tik ) d;
(14)
P( 6 Wk 6 + tki ) d:
(15)
Eq. (11) then becomes E(Wk ) = E(WF ) −
k −1
i E(Wi ) −
i=1
+
m i=k+1
i E(Wk ) −
∞
=tki
∞
=tik
P( 6 Wi 6 + tik ) d
P( 6 Wk 6 + tki ) d :
(16)
This is a complex integral recursive function from which it is diIcult to extract E(Wk ). Due to the analytical complexity of the dynamic scheduling scheme, we resort to implementations and simulation for the case of no-arrival jobs.
4. Implementation Multi-programmed System Designers often implement priority queuing disciplines expecting to improve system performances. In the case of no arrivals, that is rki = 0, for all i = 1; : : : ; n and k = 1; : : : ; K, and in discrete time, the service time of a job can be modeled as a counting process and can be considered as a renewal process. The only well-known results in the renewal theory are those when service time has an exponential or normal distribution [24], the residual times service which correspond to our waiting times are respectively, exponential or Normal. We do not simulate for other distributions. The scheduling duration is 100 s. Jobs have a service time drawn from an exponential distribution with a rate of 0.5. The system contains three jobs, the period duration is TS = 1. Bounds are m = 5; M = 5. The initial priorities are P1 (0) = 6; P2 (0) = 10 and P3 (0) = 15. Plotted priorities are shown below in Fig. 4. This Fgure shows that, by increasing the value of the time, the priorities converge to a common value at about 11.90 or 12. In a deterministic case this value is the sum of the priorities over the number of jobs in the system. In each instant this sum is constant. As expected, the processor is shared in an asymptotic way. Other examples are treated in the case where service time are drawn from a normal distribution. To theoretically and practically draw an exponential or normal law, we need a uniform distribution. We have plotted the graphics of the evolution of the priorities in the uniform case. Graphically the scheduling is almost asymptotically fair. The reason is that if the service time is drawn from a uniform law, the waiting time for servicing at any instant t may not be uniform.
A. Derbala / Computers & Operations Research 32 (2005) 229 – 238
237
Fig. 4. Jobs priorities evolution.
5. Conclusion A new scheduling scheme, a single server queuing model with several classes of customers and priorities is considered. The priorities are discretely and dynamically changing. The scheduling rule called mean bounded priority with arrival pattern, for short MBPAP, prioritizes jobs by an index computed for each job as a weighed sum of the proportion of time, it has been processed and the proportion of time it has been waiting for processing. We derived equations for the mean waiting times of a class-k customer. The result is Formula (16). The right-hand side of the expression involves some integral. We brieMy have indicated some simulation results that might give some insight into the priorities. Plots were drawn. Further investigation is needed in order to compare the performance of diKerent assignment policies. The asymptotic fairness criterion will be considered.
Acknowledgements I am very grateful to Professor Christian Proust of the Computer Science Laboratory of E3I of the University of Tours in France, where a part of this research has been conducted, for his interest and guidance in conducting this research.
238
A. Derbala / Computers & Operations Research 32 (2005) 229 – 238
References [1] Haro C, Proust C. Un Ordonnancement Equitable par PrioritPes BornPees. In Actes du colloque international, MPethodes et outils d’aide aR la dPecision, MOAD’92. Algeria: BPejaia, 1992. p. 46 –9. [2] Jaiswal NK. Priority queues. New York: Academic Press, 1968. [3] Balachandran KR. Parametric priority rules: an approach to optimization in priority queues. Operations Research 1970;18(3):526–40. [4] Balachandran KR. Queue length dependent priority queues. Management Science 1971;17(7):463–71. [5] Balachandran KR. Purchasing priorities in queues. Management Science 1972;18(5):319–26. [6] Cobham A. Priority assignment in waiting line problems. Operations Research 1954;2:70–6. [7] Holtzman JM. Bounds for a dynamic priority queue. Operations Research 1971;19(2):461–8. [8] Hooke JA, Prabhu NU. Priority queues in heavy traIc. Operations Research 1971;8(1):1–9. [9] Jackson JR. Some problems in queuing with dynamic priorities. Naval Research Logistics Quarterly 1960;7:235–49. [10] Jackson JR. Queues with dynamic priorities. Management Science 1961;1:18–34. [11] Jackson JR. Waiting time distributions for queues with dynamic priorities. Naval Research Logistics Quarterly 1962;9:31–6. [12] Jaiswal NK. Preemptive resume priority queue. Operations Research 1961;9(5):732–42. [13] Nelson RD. Heavy traIc response times for a priority queue with linear priorities. Operations Research 1990;38(3):560–3. [14] Prabhu NU, Reeser PK. A random family of queuing systems with a dynamic priority discipline. Mathematics of Operations Research 1985;10(1):24–32. [15] Takacs L. Priority queues. Operations Research 1964;12(1):63–74. [16] Tantawy AN, Tantawi AN, Serpanos DN. An adaptative scheduling scheme for dynamic service time allocation on a shared resource. In Proceedings of the 12th International Conference on Distributed Computing system. Yokohama, Japan, 1992. p. 294 –300. [17] Bagchi U, Sullivan RS. Dynamic non-preemptive queues with general linearly increasing priority queues. Operations Research 1985;33:1278–98. [18] Danieljan EA, Liese F. The analysis of a Mr =Gr =1=∞ model time dependent priorities. Rostock. Mathematiks. Kolloquium. 1991;43:39–54. [19] Knessl C. A simple model for servicing priority traIc. IEEEE Transactions on Automatic Control 2001;46:909–14. [20] Netterman A, Adiri A. A dynamic priority queues with general concave priority functions. Operations Research 1979;27:1088–100. [21] Kleinrock L. Queuing systems, vol. II: computer application. New York, London, Sydney, Toronto: Wiley, 1976. [22] Takagi H. Queuing analysis. Vacation and priority systems, vol. 1. Amsterdam: Elsevier Publishers, North-Holland, 1991. [23] WolK RW. Stochastic modeling and the theory of queues. Englewood CliKs, NJ: Prentice-Hall, 1989. [24] Aissani A. ModReles stochastiques de la FabilitPe. Algiers, Algeria: OPU, 1994.