M/G/1 variants and Priority Queue Cheng-Fu Chou Cheng-Fu Chou, CMLab, CSIE, NTU HW. 1 M/G/1 with bulk service Consider an M/G/1 system with bulk service. Whenever the server becomes free, he accepts 2 customers from the queue into service simultaneously, or , if only one is on queue, he accepts that one; in either case, the service time for the group (of size 1 or 2) is taken from B(x). Let qn be the number of customers remaining after the nth service instant. Let vn be the number arrivals during the nth service. Define B*(s), Q(z), and V(z) as transforms associated with the random variables x, q, v as usual. Let r= lx/2 P. 2 Cheng-Fu Chou, CMLAB, CSIE, NTU – Using the method of imbedded Markov chain, find E(q) in term of r, P(q=0) =p0. – Find Q(z) in term of B*(.), p0, p1= P(q=1) – Express p1 in terms of p0 Ans: (a) E[q]= r + (2(1-p0)+l2E[x2]-4r2)/(4(1-r)) (b) Q(z)= B*(l-lz) (p0(1-z2)+p1z(1-z))/(B*(l-lz)-z2) (c) p1 = 2(1-p0-r) P. 3 Cheng-Fu Chou, CMLAB, CSIE, NTU (a) Clearly wecan write qn 2 vn 1 qn 2 qn 1 qn 1 vn 1 qn 1 v qn 0 n 1 Introducing thefunction 2 k2 2, k k 0 k 2 We haveq n 1 q n - 2,q n v n 1 , lettingn and takingexpection q q - E[ 2,q ] v But E[ 2,q ] 2,k P[q k ] k 0 P [q 1] 2P [q k] k 2 p1 2(1- p 0 - p1 ) So, v E[ 2,q ] 2 - 2p0 - p1 P. 4 Cheng-Fu Chou, CMLAB, CSIE, NTU HW2 M/G/1 (service time) Consider an M/G/1 queueing system in which service is given as follows. Upon entry into service, a coin is tossed, which has probability p of giving Heads. If the result is Heads, the service time for that customer is 0 seconds. If Tails, his service time is drawn from the following uniform distribution: f(x)=1/(b-a), if a<x<b; otherwise f(x)=0 – Find the average service time x – Find the variance of service time – Find the expected waiting time – Find W*(s) P. 5 Cheng-Fu Chou, CMLAB, CSIE, NTU M/G/1 with vacations Consider a first-come-first-served M/G/1 queue with the following changes. The server serves the queue as long as someone is in the system. Whenever the system empties the server goes away on vacation for a certain length of time, which may be a random variable. At the end of his vacation the server returns and begins to serve customers again: if he returns to an empty system then he goes away on vacation. Let – F ( z) f j z j be the z-transform for the number of customers awaiting service j 1 when the server returns from vacation to find at least one customer waiting P. 6 Cheng-Fu Chou, CMLAB, CSIE, NTU (a) Derive an expression which gives qn+1 in term of qn, vn+1 and j (b) Derive Q(z) in term of p0 (c) Show that p0 = (1-r)/F1(1), r = lx (d) Assume now that the service vacation will end whenever a new customer enters the empty system. For this case find F(z) and show that when we substitute it back into our answer for (b) then we arrive at the classical M/G/1 solution. P. 7 Cheng-Fu Chou, CMLAB, CSIE, NTU (a) Clearly,if q n 0, q n 1 q n 1 v n 1 as for theusual M/G/1 system If q n 0 theservergoes on vacation and does not begin servinguntil thereare f 1 in thesystem. T hus,q n 1 f - 1 vn 1 for q n 0. Let f,k k k 0 f k 0 So, q n 1 f,k 1 v n 1 P. 8 Cheng-Fu Chou, CMLAB, CSIE, NTU (b) We have f, qn -1 v n 1 Q n 1 (z) E[zq n1 ] E[z ] E[zv n1 1 ]E[z f, qn ] by indepenedence of vn 1 , f, q n . Lettingn we find Q(z) and E[z f, q V(z) E[z f, q ] z ] E[z ]p[q 0] z k p[q k ] f k 1 F(z)p0 [Q(z)- p 0 ] p 0 (1- F(z)) Q(z) V(z) and V(z) B * (l - lz) V(z) - z p (1- F(z)) Q(z) B * (l - lz) 0 B * (l - lz) - z Cheng-Fu Chou, CMLAB, CSIE, NTU P. 9 (c) From (b), we have p (1- F(z)) Q(z) V(z) 0 V(z) - z T o determinep 0 , we evaluatetheabove eqn. at z 1 (using L' Hospitalrule).T hen, p 0 (1- F(z)) Q(z) 1 lim V(z) z 1 B * (l - lz) - z p 0 (-F(1) (1)) p 0 F(1) (1) (1) B * (0)(-l ) - 1 1- l x 1- r p 0 (1) F (1) Cheng-Fu Chou, CMLAB, CSIE, NTU P. 10 (d) In t hiscase, f1 1 and f k 0 for k 1. So, F(z) z and F(1) (1) 1, p 0 1 - r . (1- r )(1- z) Q(z) B * (l - lz) B * (l - lz) - z which is t heP - K t ransform equat ion for M/G/1 P. 11 Cheng-Fu Chou, CMLAB, CSIE, NTU M/G/1 with vacations At the end of each busy period, the server goes on vacation for some random interval of time A new arrival to an idle system rather than going into service immediately, waits for the end of the vacation x1 x2 x3 x4 v1 v2 v3 x5 P. 12 Cheng-Fu Chou, CMLAB, CSIE, NTU Let v1, v2, …, be the duration of successive vacations taken by the server and they are i.i.d. r.v. Observation – A new arrival to the system, waits for the completion of the current service or vacation o So, the waiting time formula W = R/(1-r) is still valid – R is the mean residual time for completion of the service or vacation P. 13 Cheng-Fu Chou, CMLAB, CSIE, NTU By using the same graphical argument rt x1 x1 x2 time t v1 v2 xM(t) P. 14 Cheng-Fu Chou, CMLAB, CSIE, NTU Residual service time for an M/G/1 system with vacations – M(t): # of services completed by time t – L(t) : # of vacations completed by time t t 1 1M (t ) 1 2 1 L (t ) 1 2 R r (t )dt xi vi t0 t i 1 2 t i 1 2 M (t ) L (t ) 1 2 1 2 xi vi M(t) i 1 2 L(t ) i 1 2 * t M(t) t L(t ) P. 15 Cheng-Fu Chou, CMLAB, CSIE, NTU T akinglimit as t M(t) l t L(t) 1 r t(1- r ) , v t L(t) v λ x 2 ( 1 ρ)v 2 R * 2 2v R λx2 v2 W 1 r 2(1 r ) 2v P. 16 Cheng-Fu Chou, CMLAB, CSIE, NTU M/G/1 with feedback queue Consider an M/G/1 system in which a departing customer immediately joins the queue again with probability p, or departs forever with probability q = 1- p. Service is FCFS, and the service time for a returning customer is independent of his previous service time. Let B*(s) be the transform for the service time pdf and let B*T(s) be the transform for a customer’s total service time pdf. (a) Find B*T(s) in term of B*(s), p and q (b) Find QT(z) (c) Find N, the average number of customer in the systsem P. 17 Cheng-Fu Chou, CMLAB, CSIE, NTU (a) Conditioning on thenumber of return t rips, we have B*T ( s | exactlyn return t rips) (B* (s))n 1 Unconditioningyields B ( s ) BT* ( s | exactlyn return t rips)p(exactly n rest urn trips) * T n 0 n 0 n 0 (B* (s))n 1 qpn qB* ( s ) [ pB* ( s )]n P. 18 Cheng-Fu Chou, CMLAB, CSIE, NTU (b) In determining the number in the system, we may assume that a customer cycles backs directly into service instead of to the tail of the queue. This is allowed due to the “memoryless” selection of a new service time each time a customer returns in addition to the independence of the feedback decision. Thus, we may consider our queue as an M/G/1 system with B*T(s) as the transform for the service time. P. 19 Cheng-Fu Chou, CMLAB, CSIE, NTU (1 rT )(1 z ) QT ( z ) B (l lz ) * BT (l lz ) z * T * qB (s) lx * whereBT and rT * 1 pB ( s) q P. 20 Cheng-Fu Chou, CMLAB, CSIE, NTU (c) For M/G/1, N r l x 2 2 2(1 r ) . l xT So, N rT 2(1 rT ) 2 2 P. 21 Cheng-Fu Chou, CMLAB, CSIE, NTU Priority Queue M/G/1 system with n different priority classes – class 1 > class 2 > class 3 >… – Arrival rate: lk – Mean service time: xk = 1/mk – Second moment of service time: xi 2 P. 22 Cheng-Fu Chou, CMLAB, CSIE, NTU Nonpreemptive priority A customer undergoing service is allowed to complete service without interruption even if a customer of higher priority arrives in the meantime. A separate queue is maintained for each priority class – Goal: find an equation for average delay for each priority class – Total n classes – NQk: average number on queue for class k – Wk: average queueing time for class k – rk = lk/mk: system utilization for class k – R: mean residual service time P. 23 Cheng-Fu Chou, CMLAB, CSIE, NTU 1 Assume that W1 R N Q1 μ1 overall system utilization is less By Lit tle's result than 1, i.e., r1 r2 ... rn < 1 N Q1 λ1W1,W1 R 1 ρ1 similarly, W2 R W2 1 1 1 2 1 NQ N Q λ1W2 μ1 μ2 μ1 R ρ1W1 1-ρ1-ρ2 R W2 ( 1-ρ1 )(1-ρ1-ρ2 ) Cheng-Fu Chou, CMLAB, CSIE, NTU P. 24 T hederivationis similar for all priorityclasses k 1 Wk R (1- r1 - r 2 - ...- r k -1 )(1- r1 - ...- r k ) T heavg. delay per customerof class k is 1 Tk wk mk Moreover,themean residual service timeR 1 n R li xi2 2 i 1 n Wk 2 l x i i i 1 2(1- r1 - r 2 - ...- r k -1 )(1- r1 - ...- r k ) Cheng-Fu Chou, CMLAB, CSIE, NTU P. 25 HW Consider a nonpreemptive system and 2 customer classes A and B with respective arrival and service rate lA, mA, and lB, mB . If mA > mB show that the average delay per customer (avg. over both classes) T = lATA + lBTB/(lA+lB) is smaller when class A with higher priority (class A > class B) than the case when class B with higher priority ( class B > class A) P. 26 Cheng-Fu Chou, CMLAB, CSIE, NTU Preemptive resume priority Service of a customer is interrupted when a higher priority customer arrives and is resumed from the point of interruption once all customers of high priority have been served. P. 27 Cheng-Fu Chou, CMLAB, CSIE, NTU 1. 1 mk k 2. Rk , where R k 1 - r1 - ...- r k 2 l x i i i 1 2 Rk k 1 3. Tk r i Tk m k 1 - r1 - ...- r k i 1 1 1 T1 m1 1 r1 R1 1 r1 1 , 1 r1 ......- r k Rk mk Tk 1 r1 ......- r k -1 1 r1 ......- r k P. 28 Cheng-Fu Chou, CMLAB, CSIE, NTU CASE Study DTMC for Slotted Aloha CTMC for Wireless handoff model DTMC for 802.11 Model P. 29 Cheng-Fu Chou, CMLAB, CSIE, NTU Slotted Aloha Model The Aloha network was developed to provide radiobased data communication. – Slotted system – Collision or perfect reception – Consider m users, n of which are currently backlogged. Each of the m-n unbacklogged users is assumed to transmit independently in each slot with probability a, while each backlogged user transmits independently in each slot with probability b P. 30 Cheng-Fu Chou, CMLAB, CSIE, NTU DTMC for Slotted Aloha Let thenumber of backlogged users, n, denotethestateof theDT MC. Let A(i,n) denotetheprobability thati unbacklogged users attempt totransmit in a slot whentheDT MCis in staten and B(i, n) be thecorresponding probability for backlogged users. m n 1 a m n i a i , 0 i m -n A(i, n) i n n i B(i, n) 1 b b i , 0 i n i P. 31 Cheng-Fu Chou, CMLAB, CSIE, NTU DTMC for Slotted Aloha P. 32 Cheng-Fu Chou, CMLAB, CSIE, NTU Wireless Handoff Model Consider the performance model of a single cell in a cellular wireless communication network. – New calls arrive in a Poisson stream at the rate l1 – Handoff calls arrive in a Poisson stream at the rate l2 – An ongoing call (new or handoff) completes service at the rate m1 – The mobile engaged in the call departs the cell at the rate m2 P. 33 Cheng-Fu Chou, CMLAB, CSIE, NTU More… There are a limited number of channels, n, in the channel pool. When a handoff call arrives and an idle channel is available in the channel pool, the call is accepted and a channel is assigned to it. Otherwise, the handoff call is dropped. When a new call arrives, it is accepted provided g+1 or more channel are available in the channel pool; otherwise the new call is blocked. Here, g is the number of guard channels used to give priority to handoff calls. P. 34 Cheng-Fu Chou, CMLAB, CSIE, NTU CTMC for Handoff Model P. 35 Cheng-Fu Chou, CMLAB, CSIE, NTU DTMC for Memory Interference in Multiprocessor System The processors’ ability to share the entire memory space provides a convenient means of sharing information and provides flexibility in memory allocation The price of sharing is the contention for the shared resource To reduce contention, the memory is usually split up into modules, which can be accessed independently and concurrently with other modules When more than one processor attempts to access to the same module, only one processor can be granted access, while other processors must await their turn in a queue. P. 36 Cheng-Fu Chou, CMLAB, CSIE, NTU The effect of such contention, or interference, is to increase the average memory access time. P. 37 Cheng-Fu Chou, CMLAB, CSIE, NTU Memory modules M1 ●●● Mj ●●● Mm Interconnection network P1 ●●● Pi ●●● Pn Processors P. 38 Cheng-Fu Chou, CMLAB, CSIE, NTU Assumptions The time to complete a memory access is a constant and all modules are synchronized Processors are assumed to be fast enough to generate a new request as soon as their current request is satisfied A processor cannot generate a new request when it is waiting for the current request to be completed P. 39 Cheng-Fu Chou, CMLAB, CSIE, NTU The operation of the system can be visualized as a discrete-time queueing network P. 40 Cheng-Fu Chou, CMLAB, CSIE, NTU The memory modules are the servers and the fixed number, n, of processors constitute the jobs or customers circulating in this closing queueing network. Let qi denotes the probability that a processor generated request is directed at memory modules i, i= 1, 2, …, m. Consider a system with 2 memory and 2 processors P. 41 Cheng-Fu Chou, CMLAB, CSIE, NTU P. 42 Cheng-Fu Chou, CMLAB, CSIE, NTU Memory Referencing Behavior In the renewal model, the successive intervals between references to a given page were assumed to be i.i.d. r.v.. We consider a special case of the renewal model, where the intervals are geometrically distributed. This is known as the independent reference model (IRM) of program behavior. P. 43 Cheng-Fu Chou, CMLAB, CSIE, NTU Independent Reference Model A program’s address space typically consists of continuous pages represented by the indices 1,2,…,n. To study a program’s reference behavior, it can be represented by the reference string w=x1, x2,…,xt. Successive references are assumed to form a sequence of i.i.d. r.v. with P(xt = i) = bi, 1 i n. The interval between 2 successive references to page i is geometrically distributed with parameter bi. P. 44 Cheng-Fu Chou, CMLAB, CSIE, NTU LRU model Assume that a fixed number, m (1m n), of page frames have been allocated to the program. The state of the paging algorithm at time t, denoted by q(t), is an ordered list of the m pages in main memory. If the next page referenced (xt+1) is not in main memory, then a page fault occurs. This will, in general, require the replacement of an existing page from main memory. We will assume that the rightmost page in the ordered list q(t) P. 45 Cheng-Fu Chou, CMLAB, CSIE, NTU LRU model (cont.) If the next page referenced (xt+1) is in main memory, no page fault (and replacement) occurs, but the q(t) is updated to q(t+1) We can see that the sequence of states q(0), q(1), …,q(t),… forms a DTMC with the state space consisting of n!/(n-m)! Permutations over {1,2,…,n} Assume that the main memory is preloaded initially with m pages. P. 46 Cheng-Fu Chou, CMLAB, CSIE, NTU LRU model Example Consider the LRU paging algorithm with n=3 and m=2. Let q(t) be ordered by the recency of usage, so that q(t) = (i,j) implies that page indexed i was more recently used than page j, and page j will be the candidate for replacement. P. 47 Cheng-Fu Chou, CMLAB, CSIE, NTU P. 48 Cheng-Fu Chou, CMLAB, CSIE, NTU