It is shown that the expected deadlock time is never less than 1, no matter how
many processes and resources ... G.2.2 [Discrete Mathematics]: Graph Theorypfk.
Expected
KEVIN
Deadlock
J.
Time
COMPTON
AND
in a Multiprocessing
CHINYA
System
RAVISHANKAR
Unmermy of Mzchigan, Ann Arbor, Mdzigan
Abstract. We consider multiprocessing systems where processes make independent, Poisson distributed resource requests with mean arrival time 1. We assume that resources are not released. It is shown that the expected deadlock time is never less than 1, no matter how many processes and resources are in the system. Also, the expected number of processes blocked by deadlock time is one-half more than half the number of initially active processes. We obtain expressions for system statistics such as expected deadlock time, expected total processing time, and system efficiency, m terms of Abel sums. We derive asymptotic expressions for these statistics in the case of systems with many processes and the case of systems with a fixed number of processes. In the latter, generahzations of the Ramanujan Q-function arise. We use singularity analysis to obtain asymptotlcs ot coefficients of generalized Q-functions. Categories and Subject Descriptors: D.4, 1 [Operating Systems]; Process Management—deadlocks; multiprocessmg/multtprogrammmg; F.2.2 [Analysis of Algorithms and Problem Complexity]; Nonnumerical Algorithms and Problems—computations on dtscrete structures; G.2. 1 [Discrete Mathematics]; Combinatorics—generatingfunctlons; G.2.2 [Discrete Mathematics]: Graph Theorypfk and circuit problems General
Terms:
Additional analysis
Key
Performance, Words
Theory
and Phrases:
Asymptotic
analysis,
expected
time
analysis,
singularity
1, Introduction Deadlock cessing
detection systems
for example)
and resolution
(see Bic
deadlock
and
is rare
Shaw
is a major [1988]).
issue in the design
Although,
in some
and the cost of resolution
(such as database systems) the likelihood resolution requires an expensive rollback
of multipro-
systems
(Unix,
is low, in many
others
of deadlock may be quite high and and recovery. It would be useful to
know under what circumstances deadlock is likely and (especially when resolution is costly) the expected time for the occurrence of deadlock. This paper presents requests
a model of multiprocessing systems where processes make resource independently and with Poisson distributions of mean 1. We derive
K. J. Compton would like to express his appreciation to the Institut Informatique et en Automatique and l’Ecole Polytechnique for partial this research was done. He would also like to thank the members of prowdmg a supportive research environment and good camaraderie year. Authors’
present address: EECS Department,
University
of Michigan,
National de Recherche en support during the period Projet Algo at INRIA for in the 1991–92 academic
Ann Arbor,
MI 48109-2122.
Permission to make digital/hard copy of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for proht or commercial advantage, the copyright notice, the title of the pubhcation, and its date appear, and notice is given that copying is by permission of ACM, Inc. To copy otherwise, to republish, to post on servers, or to redistribute to lists, requires prior specific permission and/or a fee. @ 1995 ACM 0004-5411 /95/0500-0562 $03.50 Journal of the As.o.,dtmn fm COmputmgMachinery,Vd 42, NO 3, Mq 1W5, pp 562-587
Expected
Deadlock
Time
563
o
❑
P,
P2
P3
P4
..
FIG. 1.
P5
A resource
allocation
graph.
P6
PI
•1
P8
Resources
exact
Processes
and asymptotic
deadlock,
expressions
expected
simplifying
total
assumption
be viewed
as upper
Let us describe composed
that
bounds
time,
resources a little
of entities:
statistics
such as expected
and system
are never
or bounds
our model
of two types
for system
processing
efficiency.
released.
for an extreme
more
precisely.
processes
Thus,
time
We make our results
case of system
may
behavior.
A multiprocessing
and resources.
to the
system is
Processes
are the
active entities of the system. They can change the system state by requesting new resources or releasing resources allocated to them. Resources are serially reusable: they may be reallocated once they are released. Examples of such resources are hardware units such as memory pages or printers, and software resources such as database locks. We do not examine systems with consumable resources process
such as messages, requests
only
signals,
one resource
A system state is represented graph
whose
is bipartite;
vertices edges
are
free,
p releases an edge
released. requests inactive appears
from
We also assume
that
each
been
and resources resources allocated
graph.
This is a directed
in the system.
to processes
The graph
or processes
to a process.
If a process
to p
r, an edge is inserted in the resource allocation graph that r has been allocated to p and is no longer free.
r the edge is erased.
is drawn
In this
directed
1). if it has not
requests a free resource from r to p to indicate
data.
by a resource allocation
are the processes
resources (see Figure A resource is free
When
and input at a time.
from
If p requests
p to r, indicating
case, p becomes
inactiue
that
or blocked
a resource
r that
p is waiting
for
and can make
is not r to be
no more
until r is released. Thus, an active process has out-degree O and an process has out-degree 1. Deadlock occurs when a directed cycle in the resource allocation graph. Since all the processes on the
directed cycle are blocked, the resources on the cycle can never be released. They become useless until the deadlock is detected and resolved. For example, if process p ~ requests resource r4 in Figure 1, deadlock occurs because a cycle
K. J, COMPTON
564
AND
C. RAVISHANKAR
p7 + r4 + p2 + r2 + p3 -+ T5 + p7 results when the edge p~ ~ rd (indicated by the dotted arrow) is added. A more detailed description of the model is given in the following section. Lynch [1994], in enumerating the number of cycle-free resource allocation graphs for given numbers of resources necessary and sufficient conditions for resource
allocation
graph.
(i)
Every
vertex
(ii)
Every
resource
To see this,
and processes, used the following a bipartite directed graph to be a
has out-degree with
observe
at most
non-zero
that
one.
in-degree
a resource
has out-degree
acquires
exactly
an out-edge
one,
the first
time
it is
requested; thereafter, it acquires only in-edges. A process, on the other hand, acquires in-edges until it acquires its first out-edge; thereafter, it is inactive. (For more general models of deadlock and associated references, see Bic and Shaw [1988].) From his enumeration, Lynch model where resource allocation edges are equally to problems
likely.
such
Flajolet
[1990]),
[1988]
and Flajolet
Our
as linear
[1994] derived some system statistics for a graphs with the same number of directed
model probe
computation
is quite hashing
of random
mapping
[1990a]),
analysis
Yao [1976] and Knuth and Schonhage Knuth [1985]). These problems are all
[1978]), analyzed
called Abel’s The
because identity). outline
and Odlyzko
different.
many
of them
of the paper
and derive recurrence note that all of these terms
of Abel
can be evaluated is as follows:
from
a result
any state with
[1973]
statistics
and optimum in terms of explicitly
In Section
related
Vitter
and et al.
algorithms
(see
caching (see Abel sums (so
by generalizations
2, we describe
our
of model
statistics. In Section 3, we form and give solutions in
we call the Half j active
closely and
(see Flajolet
of union-find
relations for various system recurrences have a common
sums. We prove
says that beginning
It is more
(see Knuth
and Half
processes,
Theorem.
the expected
It
number
of these processes blocked by deadlock time is (j + 1)/2, one-half more than half the number of initially active processes. In Section 4, we develop a general theory for the evaluation of Abel sums. This is applied to the recurrence solutions of Section 3 to give expressions and inequalities for system statistics. In Section 5, we give asymptotic expressions for these expressions in the case where
systems
where systems the Q-function
have many
processes.
have a fixed number arise, This function
In Section
6, we do the same for the case
of processes. Here, functions was studied by Cauchy [1826],
generalizing and later by
Ramanujan [1912]. Ramanujan actually denoted it 6’ (as he did several other functions). Knuth was the one to name it Q in his first expected time analysis of an algorithm [Knuth 1968, pages 113–1 18] (see also Flajolet, et al. [1992]). We use singular expansions to obtain the asymptotic of coefficients of functions of this type. We observe several notational conventions. The expression [z” ]s(z) denotes the rzth coefficient of the generating function s(z). The expression nn denotes the falling
factorial
rz(n – 1) .”. (n – m + 1). Stacked
numbers
in braces
/:;, )
denote Stirling numbers of the second kind (or in the terminology of Graham et al. [1989] the subset Stirling numbers). The expression j!! denotes the double factorial function 1.3 “ 5 “”” (2j – 1). E(M is the expectation of the random
Expected
Deadlock
Time
variable
X. We write
another
way of writing
2. Recurrence In this
~ < g if ~(n)/g(n) ~(n)
approaches
O as n ~
~; this
is just
= o(g(n)).
Equations
section,
recurrence
565
we give
relations
a more
for system
detailed
description
of our
model
and derive
statistics.
Let m be the number of resources and n be the number of processes in a multiprocessing system. Suppose that the system has just entered a state where there are i free resources and j active processes. Let ~, ~ be a random variable representing the time to deadlock. ~, ~ depends on m as well as i and j, but for notational
convenience
we suppress
m. We shall
see that
~, ~ does not depend
at all on n. Consider active
the
process,
able with
arrival
mean
exponentially
time
this value
1. For j active distributed
calculation
shows that
mean
That
j-l,
for
the
would
next
request.
processes,
random
variables
express
the
with
mean
distributed
arrival
were
just
distributed
it is the minimum
this is an exponentially
is, we may
If there
be an exponentially
time
a single
random
vari-
of j independent, 1. A
straightforward
random for
the
variable
next
with
request
as
j-lXl,,, where X,:~ is an exponentially distributed random variable with mean 1. Thus, after a time interval of length j- lX,,,, a process p chooses a resource r. Now r may be one of the i free resources or one of the m – i allocated resources. where serted free
The
P[A,,,
event
that
r is free
is represented
by a random
variable
~,,,
= 1] = 1 – F’[xl,,l = 0] = i/m. When A,,l is 1, an edge is mr to p and the system enters a new state in which there are i – 1
from resources
edge inserted
and from
j active
processes,
p to r would
result
When
zl,,~ is O, we check
in deadlock.
to see if an
We do this by constructing
a directed path from r as follows: Follow the unique out-edge from r to a process. If this process has out-degree one, again follow the unique out-edge. Continue in this fashion. The resource allocation graph contains no directed cycle yet, so this path terminates. In fact, it terminates at a process, since resources with non-zero in-degree have out-degree one. If the process in which this path terminates is p, an edge from p to r would complete a directed cycle and deadlock processes, not occur represented (j
– I)/j.
results.
we do not
If the path have
is (j – 1)/j. by a random Putting
terminates
deadlock.
Thus,
at any of the the probability
other that
j – 1 active deadlock
does
The event that deadlock does not occur may be variable B,, ~ where P[ B,, ~ = 1] = 1 – P[B,, ~ = 01 =
this all together,
we have (1)
where the random variables Al, ~ and B,, ~ are independent of each other and of the random variables X,,,, ~_ ~ ~, and ~, ~_,. This model is counterintuit’ive in one respect. Suppose that process p requests a resource r and at some later time p requests r again. This is not precluded in our description of the model. The system enters deadlock at this point because a 2-cycle appears in the resource allocation gralph. If we do not allow the possibility of a process requesting a resource already allocated to it, then the system may never reach deadlock. It may instead reach a state in which all resources have been allocated to a particular process and all other processes are blocked. If we wanted to forbid the possibility of a process
566
K. J. COMPTON
requesting
a resource
already
allocated
about what we mean by expected for considering the former model
to it, we would
AND
C. RAVISHANKAR
have to be more
careful
deadlock time. Of course, the main reason is that it is analytically more tractable.
In the case in which there is a single famous birthday problem (see Krmth
process, [1968]).
our model is an instance of the This problem asks how many
people one must choose at random to find a pair with the same birthday. is equivalent to labeling 365 resources with the days of the year (we ignore days) and computing occurs
only
number
a resource
of people
Closely problem
the expected
when
one must
related
deadlock
choose
to the problem
of finding
the total
time,
is repeated.
In
which,
for a year with
of finding
processing
with
general,
just
one process,
Tw, ~ is the
expected
m days.
the expected deadlock time is the This requires P,,, before deadlock.
time
only a minor modification if j processes are active
of the argument used to derive eq. (1). Observe for a time interval given by j- IX,,,, then the
processing
interval
time
over that
=Xl,,
~,, Now using
if we let linearity
is Xl,,.
+A[,,~_l,
~,1 = E(~,,)
that, total
Hence,
J + (1 –At,
J) Bz, jP,,, _l.
P,,l = E(P,, I ), from
and
of expectation
This leap
and independence,
then
(2)
(1) and
(2) we have,
multiplying
by j,
(3)
(4) for ~ >0. A system measures in which total
statistic
system
j processes
processing
processes We will
that
will
efficiency.
be especially Note
that
is total
a time
interval
are active
for
to this
quantity
time
important
jT1,,
is the
is ~ ~ = P,, ,/j~, processing
time
of T,,,. The
expected
ratio
fraction
~ which
in a system of actual
of time
that
are active. also be interested
in the variances
of
~,,
and
P,,,. Therefore,
we
wish to compute the expectations ~ ~ = E(Tl~J ) and Q,,, = E(P,~, ). Squaring both sides of (1) and using the identities A,, j(l – Al,,) = 0, A~,, = A,,,, (1 – A,,,)z = 1 –A,,,, B~l = B, ~, we have
+2j-]X,,, Now take expectations
A,,, ~_l,,
+ 2j-lx,,
and use eq. (3). Note
J(l that
–A,,,~B, E(X~,)
,~,l-I.
= 2. Then
multiply
by
j to obtain
jVJ Performing
= 2T,1
the same series
i + ~j~-~,l
+
of computations
l–~ (
(j–l)~,,.l.
(5)
“1 beginning
with
(2), we have
(6)
Expected
Deadlock
Time
567
SJmlml
Descrlptlon
s LJ
z]
Expected
IT, ,1
1
(3)
j Pi.:
J
(4)
‘j U,,j
2T, ~
(s)
jQ,,,
2JP,,l
(6)
JR, ]
t~/m
(7)
x,,
Equdt ]on
Deadlock T]me e,
Expected Total Processing Time
uJ]
Expe( ted Square
FIG. 2.
Summary
of recurrences.
of Deadlock Time E\pected
Q, J
Square of
Tot al Processing Time R,,
Expected Number of Resources Allocated
The last statistic we consider resources. This is also important deadlock
time
requesting expected occurs.
is fairly
long,
resources number
This
measures how well the system for system design. Even if the
system performance
are usually
blocked.
if processes
therefore,
in the
of resources
a resource,
.. jR,, j = xm
the probability
i + ;jRl_l,,
that
+ (
The
be poor
are interested,
R, , that will be allocated by the time deadlock is easy to determine from our model. Notice that whenever a
process requests i/m. Thus,
3. Solving
still might
We
allocates expected
the General
eqs. (3)–(7)
the request
1 – ~ (j m“)
will
be granted
– l) R,,J_l.
is
(7)
Recurrence
have the form St,, = X,,j
+
+( “)
h,_l>J m
1 – ~ m
st,, _,,
(8)
where
S,, ~ = Xl, ~ = O for all i. (Note that there is no need to specify the values of so , since SO,~ = Xo, ~ ~ So, ~– 1.) We summarize the results of the previous section, with respect to this general form, in Figure 2. Recurrence (8) is linear in Xi, j; that is, if X,,, = aX~,, + bX~, for all i and j, then S,,, = aS~,, + bS,,, where $,, and S: ~ are solutions of the obtained from (8) by replacing X,,, with X;, ~ and X:,, respectively. To solve (8), we might and solve the resulting to this equation
function. .
St(z)
easily
Instead,
generating
equation.
for s,(z)
=x,(z)
x,(z)
+ q(z) m
gives an expression
+ in terms
x,(z)
= m–(m–i)z
=
j >1
for coefficients
of generating ixl,lz~. 1=1
to obtain
( “) 1 – ~ m
of s,_ Jz)
2$(Z). and xl(z): st_l(z).
+ m–(m–i)z
Z,,, S,,, y’z] the solution
i
m s,(z)
solution
sequences
and
~ St,,.d ]=1
function
Unfortunately,
to a closed-form we form
eq. (8) by z~ and sum over the range s,(z)
Solving
=
a bivarlate
differential
does not lead
of the generating
Multiply
try to form partial
equations
functions
568
K. J. COMPTON
Substitute for s,_ ,(z) on the right sl _ Z( z), and so on. We have
s,(z)
side of this
=
AND
expression,
C. RAVISHANKAR
then
substitute
at, k(z)x~(z).
~
for
(9)
k=O
where n’zi(i a,, k(z)
1)...(k + 1)
-
= (m
-
(m
-i)z)(m
+ 1)2) ”””(WZ – (m -k)z)
– (n? -i
It is instructive to use (9] and (10) to compute expectation in the birthday problem for a year with i > () and j > 0. Then, T~ ~ is the linear coefficient sum of the constant
We may regard jan Q-function. a family
of the Q-function In a later section,
– 2)
+
. . +(~
-
l)(m -2)...1 m—1 m
of m, The function T~, ~ – 1 is the Ramanucoefficient of s~(z) and thus is just the first
given
used by Knuth
T~, ~, which, recall, is the m days. Take Xl,, = 1 for of s~( z) and hence is the
m’
this as a function T~, ~ is the linear
of functions
techniques
(lo)
of am, ~. Thus,
(7?’2– l)(nl
m–l ———— + m
Tm.1 =1+1+
of
coefficients
“
by the
and others
successive
to obtain
coefficients
of
the asymptotic
s~(z).
The
of coefficients
do not seem to extend easily to other functions in the family. we will develop other asymptotic methods to deal with these
functions. Let tion,
us return
to our analysis
of (9) and (10). By partial
fraction
decomposi-
Thus,
[2’1%,(2)
=
i
(-l)
’-’(i
_ ,,/_
~,k)(l
-
;)[-’+’
l=k
and consequently
s,,,
=
~ ‘il([z’laL, k=or=o
k(z))
([z’-’
lxk(z)) L–k+r
_ —
~’~’ k= Or=
=
=
}.(;)
i%+
~=1
&l)
’-k(i_l,
;_~,
~
l–~ )(
Ol=k
:O(;](;
-
i
1=1
(f)>o(~j(;
l)
’-k:~(l
-
-
1)[-’2J
m
‘k]-r
)
;)[-’+’%
-
;]
’-’’’x,,,_r.
,11,
Expected This
Deadlock
appears
considerable
a little
cumbersome,
then
be evaluated introduce
but
for
In particular,
many
choices
of
X,,J
if X, ~ can be written
there
is a
as a product
we can write
1{ = 1 – l/m.
The
separately.
sums
Z~. ~(~)y,(-ll)i-’
Results
below
and
follow
Z;j~ZJ.,l~
in this way.
can then
It is convenient
to
the notation
c,(P, Note
569
simplification.
X,,, = ~Z,
where
Time
that
explain
!l)
Ji)(:)[-p(l$+’
=
z
+ 1,q + 1) = Ci(p
c,(p
(13)
~
+ 1,q) – c,(p,
how Ci(p, q) may be computed
in closed
q).
form
In the
next
section,
for some values
we
of p and
q. 3.1.
THEOREM
expected deadlock (i) (ii) (iii)
We have the following
total processing time.
time,
and
expressions
expected
for
number
expected deadlock
of resources
time,
allocated
at
~,, = 1 + (Ct(l, O) – Cl(l, j))/j. 1)/2 + C,(l, O) - (C,(2, 1) - C,(2, ~ + I))/j. P, R:,, = c,(l, O) – (c,(2, 1) – c,(2, j + 1))/”. j
=
(~
+
For
PROOF.
Binomial
(i),
Theorem
take
(ii)
(8)
so that
of geometric
eq.
series
1( = = 1(1 _ ~)~-1
(;)k(-~l)’-k
k=O
]–1
1, – q+l (15)
~(j-r)I[=&~=o which Parts
are derived (ii)
by standard
and (iii)
1 ❑
techniques.
of the theorem
(1 - 1{)2 ‘
already
provide
useful
information
about
system behavior. The expected total processing time Pi, ~ is also the expected number of requests since the request arrival time for each process is 1. The number of resources difference between this value and R,, ~, the expected allocated, is the expected number see that this quantity is always (j
of processes blocked by deadlock time. We + 1)/2, one half more than half the number
of initially active processes. system performance.
we have the following
THEOREM
3.2
(THE
with j active processes, time is (j + 1)/2.
HALF
Thus,
AND
HALF
the expected number
THEOREM).
surprising
Beginning
result
from
of these processes blocked
about
any state
by deadlock
570
K. J. COMPTON
AND
C. RAVISHANKAR
There is an easier way to prove the Half and Half Theorem. The theorem is clearly true when j = 1. Now suppose the system is in a state where the number
j of active
Theorem number
holds for states with j – 1 processes. The system may change states a of times before it changes from a state with j active processes to a
state with of active state l/j;
processes
j – 1 active processes
change.
is more
processes.
decreases
The
in this event, just
Let
critical.
probability
than
one and assume
us call state A system
of deadlock
changes
where
can deadlock
at the
one of the original
the Half
first
processes
the number
only
critical
and Half
at a critical
state
is blocked.
change
is
The probability,
then, that deadlock does not occur at the first critical state change is (j – 1)/j; in this event, the system enters a state with j – 1 active processes and the expected
number
of remaining
processes
that will
be blocked
by deadlock
times
is j/2, by the induction hypothesis. Thus, the expected number of processes blocked by deadlock time is (l/j) + (1 + j/2)(j – 1)/j = (j + 1)/2. Using these ideas, we can determine how many processes must be blocked for the probability of deadlock to exceed deadlock after k critical state changes is 1 ~+j–l
j–l
l”””
3.3.
Before (11). free.
If we allow
concluding
Consider Changing
““”
result
a system with j initially
are blocked,
this
section,
k
1
j–k+2j–k+l=~
so we set k = tij. We have the following
until 8j of those processes is 8.
of reaching
+ j_lj_’2
j–k+l j_
probability
1
j
j_lj–’2
+——j
THEOREM
The
1 j–lj–2 —+———
j
J
8>0.
let
the probability
us explore
actiue processes that deadlock
another
the case where i = m, that is, where the order of summation we have
to operate
has occurred
consequence
all resources
of eq.
are initially
The last equation follows from formula (6.19) of Graham et al. [1989]. Although this is a more pleasing form than eq. (12) (and shows, in particular, that of the quantities X~, ,), it is not as useful. s m.] is a positive linear combination
4. Evaluation
of Abel
Sums
Abel’s identity is expressed in several different one of them (see Riordan [1968, page 18]): 1 xx [=0
j (1
(x+l)l-
l(y+i–l)’-l=
forms
in the literature.
(.x+y+
i)’.
Here
is
Expected
Deadlock
It follows
Time
immediately
571 that
1.
(x+y+i)’–(y+
X()( ;
x+l)l-l(y+i–
x
1=1 Taking
the limit
as x approaches ‘~(~)l’-’(y 1=0
If we put
O we have +i
-1)
’-’
=i(y
+i)’-’.
y = m – i and
needed to evaluate [1968, pages 18-23] give some
divide by m’-l, we have the expression in Theorem 3.l(i), considers several generalizations
of the other
some
typographical
good
asymptotic
i)’
l)’-’=
one of the cases of (13) viz., CL(l, O) = i. Riordan of Abel’s identity. These
cases c,( p, q) by the same argument.
errors results,
in Riordan’s we must
formulas.)
develop
(N.B.
However,
a more
general
There
in order theory
are
to get
for
expres-
that
C,(p,
sions of the form
and
then
evaluate
c,(p,
q, Y) is a convolution.
fp(~) =
q) = Cl(p,
q, m – i)\m’-P+~.
First
note
Let
,:1:=’
and
gq(z)
m (y + k) ’’+qz, x k! k=o
=
“
(If p = O, then it will be convenient to begin the summation for ~p(z) at k = O rather than k = 1 so that the constant coefficient is 1.) Then CL( p, q, y) = [z’/i!]fp(z)gq(z). The function ~l(z) = ~(z) is well enumeration. A standard textbook application of Formula is to show that jlz) is the solution of
known in combinatorial the Lagrange Inversion the functional equation
~(z) = zef(z) (see Wilf [19901). If we differentiate both sides of this substitute ef(z) = ~(z)/z, and solve for ~’(z) we have zfl(z) = jlz)/(1
equation, – ~(z)).
Thus, f,(z) from
which
= ~
Zf(x) y
it follows f,(z)
dx = J : (1 –f(x))f’(x)dx
=f(z)
– ;f(z)~,
that f,(x) yal
“
~
— .
z J-(
1 – :f(x)
o
=f(.z)
– ;f(z)’
If we use the Lagrange Inversion e ‘f(z) and then substitute f(z)/z for
)
(1 – f(x))
fl(x)
+ ;f(z)s. Theorem to compute ef(z), we have k–1
f(z)’
=Y
:
h=l
ah
‘y‘k:)
Zy+k,
the
coefficients
of
572
K. J. COMPTON AND
Differentiate,
multiply
by
z,
and
replace
z~’(z)
with
_
f(z)
y
–
— (1 z
C. RAVISHANKAR
~(z)/(1
– ~(z)).
We
obtain
m (y+k)’zk go(z)= It follows
~ L=o
~, “
1 1 –f(z)
“
that
fl(z)go(z)
‘+’
f(z) — () z
= z
1 1 –f(z) k– 1
=
5
‘(y
y
Zk>
k=l
and
so
C,(l,
~,(z) go(z)
We p >0.
O,y)
= i(y
+ i)[-l.
A
similar
evaluation
of
~2(z)go(z)
and
shows that c,(2,0,
y)
= i(y
+ 0-1
–
1 #(y
+ i)’-z,
c1(3,0,
y)
= i(y
+ 0-1
–
;iqy
+ ~) ‘-2
can use the method We can show easily
above to compute by induction that
f,(z)
=
i
+ :ij(y
values
of
+ ~)’-s. C,(p,
O, y) whenever
D,,kf(z)’.
k=l
where
for
all positive
p,
DP, I = 1 and
DP+ ~,k+ ~ = (DP, k+l
– DP, ~)\k.
These
coefficients are the “differences of reciprocals of unity” appearing on page 248 of David et al. [1966]. (This source was located with the help of Sloane [1973]; cf. sequences
2049 and 2305.) C,(p,
It follows
o,y)
=
f
that Dp,,iqy
+ i)’-k.
k=l
We can now compute values are as follows. c,(l,
the values
q) when
p > q >0.
The
first
O) = i, i(i
c,(2,0)
of c,(p,
– 1)
= im – 2’ 3i(i
c,(3,0)
i(i
– 1)
= imz –
– l)(i
4
6’ i(i
c,(2,1)
= c,(2,0)
– 2)
m+
– cz(l,
+ 1)
O) = im – 2’ (3i
c,(3,1)
= c,(3,0)
– c,(2,0)
+ l)i
= imz –
~
4 = c,(3,1)
– c,(2,1)
= imz – 4
(i + l)i(i
– 1)
6’ (i + 2)(i
(3i + 5)i c,(3,2)
+
m+ 6“
+ l)i
few
Expected
Deadlock
Time
573
In general, P Ct(p,
and values
of Cl( p, q) for
Substituting ing theorem
o)
=
~ k=l
qzi%rz~-~
1 < q < p are obtained
these values for giving expressions
by differencing.
Ci( p, q) into Theorem 3.1, we have the followfor various system statistics in terms of Abel
sums. THEOREM
4,1.
expected number (i) (ii) (iii)
~,,
The expected deadlock of resources
= 1 + i/j
P,,, = (j
-
+ 1)/2
+ i(i
+ i(i
+ 1)/2j
eq. (13), we see immediately
COROLLARY
+ 1)/2j
that
total processing
time,
and
time are as follows:
+ c,(2, j + 1)/j.
c,(1, j)
important
The expected
4.2.
upected
+ CL(2, j + I)/j.
c,(2, 1), so we have the following
and expected number
time,
at deadlock
j)/j.
+ i – ire/j
Ri,J = i – ire/j
From
c,(l,
allocated
deadlock
of resources
s c,(1, O) and
c,(2, j + 1)
i\(3(m 1
point
1 + l/(m
– l);
the
– 1)) so for all z on r
3nl 2,
and
f2(z)f-,
-l(z)
=
(j
+
l)!!
– l)(2j
&
–
[ 144j4
+ 1344j3
)
12j2 + 72j + 358-2, 48(2j + 1)
– 216j2
– 144j
– 47
+ 2304(2j+
for j >1.
By the Binomial TV2 r(a/2)
Theorem
~m+(a–
2(”-lJ/2 9a~ – 60a3
8-2]+
1
+. . . .
and Stirling’s
}
formula
[z~/rn
3a2–6a+2 (
1 + &
-1
l)(2j–1)
1)/2
1 +
+ 120a2
+
24m – 72a
1
+ 4 +o~.
1152mz
+ .+O
– 3)
( m
))
!]8-”
is
580
K. J. COMPTON
Substituting
this into
the expressions
above
(2m)l/2 c~(l,
l)
=m
–
~
and simplifying,
C. RAVISHANKAR
we have
(2*)1/~
1 + — – 3
nil/2
AND
~l–l
/’2
24
4 –’ + O(n-slz) + 135 “ 21\zr(j C,,,(l, j)
+ 1/2)
~l,z
+
2j
– 1
= nz – 3
I’(j)
21/~r(j
+ 1/2)
djz
5m-1,2
– 6j +
361’(j)
2j–1
2j2–4j–6 135 c.(2,
1 j + 1) = ~m2
m
-1 + o(n-3/2)
2j+l –
—
2m 21\zr(j
+ 1/2)
2j
+ 1
~,z
j2
+ r(j) The
asymptotic
formula
for
Cn(l,
— 3 1) agrees
m
with
+ o(n-”2)
–3
eq. (25)
[1968]. Our approach seems somewhat simpler analysis of the incomplete gamma function. From the main result of this section.
in 1.2.11.3
since it Theorem
of Knuth
does not require 4.1, we now have
THEOREM 6.1. Fix j. For systems beginning from a state with j processes and all resources free, we haz,)e the following asymptotic formulas for expected deadlock time, expected total processing time, expected number of resources allocated at
deadlock
time,
and system efficiency.
(2=)1/2 T m,l
2 + — + 3
ml/2
=
2 2’12r(j T
m>] =
(2m)”2 24
+
0(n-31~),
135 m
+ j + 1
+ 1)
2’/2(4j2
‘1
‘n
+ l/2)m1,q
r(j
4
–1/2
-
3j
– 6j + 5)1’(j
– 1/2)
+ 72r(j
_1,2 m
+ 1)
2jz–4j–6 +
135j
23/211j P
m,] =
+ 3/2)
3r(j
-1 +
311j
+ 3/2)
=:
+
~
+ O(m-1/2), 6 mll~
+ 1)
+
when
m1,z + j + 3
1 F m.]
o(n-3/2),
+ 1)
23\217(j R=m,J
‘z
o(l’wl/~).
– ;
“
+ @m-1/2),
j >2
Expected
Deadlock
Thus,
we find
processing than
that
time,
constant 2/3.
mined
Time
581
for
and
multiple
of nzl\2.
This
seems very
the order
a fixed
number
of
System
number
allocated
efficiency
promising.
of the variances
of processes,
resources
always
deadlock
and total
not
total to
a value
we have
time
time,
asymptotic
approaches
Unfortunately,
for
deadlock are
a
greater
yet deter-
processing
time
and we have no idea of the distribution. 7. Conclusions Our results suggest detection at regular
that it may be worthwhile intervals in some systems.
for this is the absolute 4.2(i)). Also, the high processes
(Theorem
lower values
5.l(iii))
bound for for system and
systems
(Theorem 6.1) are encouraging. If we knew the distribution of deadlock
to investigate doing The most compelling
expected efficiency with time
deadlock evidence
deadlock time (Corollary for systems with many
a fixed
number
~ ~ we could
of processes
determine,
for
a
given 8>0, the length of time the system must operate for the probability of deadlock to be i3. We could then compare the cost of continuously updating to do deadlock detection versus the expected cost of resolution and rollback when doing deadlock detection at regular intervals. Even though we do not know the distribution,
Theorem
3.3 provides
a similar,
but
less satisfactory,
approach.
We can count blocked processes. This requires some communication processes and may therefore cost more than waiting for a fixed time but it is still
likely
to cost less than
deadlock
prevention.
What do we have to do to determine the distribution i or j increase? A standard approach for determining random eq. (l), T: l]
This
between interval,
of deadlock time ~ , as the distribution of a limit
variable is to find its characteristic function (see Feller [1971]). ~rom we have the following recurrence for the characteristic function ~ , of
may
generating
lead
to
function
There
are other
a solution, methods important
but
it
does
not
seem
to work
well
with
the
used here. questions
First, although practice.
the absolute lower bound we theoretically optimal, certainly The most obvious reason for
sources
in multiprocessing
systems
still
to be answered.
derived for expected does not come near this is that processes
so deadlock
time
is usually
deadlock time, what occurs in do release remuch
greater
than in the model here. We need to develop a more realistic model, but this will not be easy. It will require adding a queuing-theoretic dimension to the combinatorial problem of determining when cycles emerge in certain kinds of random
bipartite
Second, We would
graphs.
we need to deal with the problem of 2-cycles mentioned expect processes to remember the resources allocated
in Section 2. to them and
to avoid making duplicate requests. As we noted, if we prohibit 2-cycles, then it is no longer clear what is meant by expected deadlock time. It is also not clear how to modify the model. Should we proceed as before with a process randomly choosing a resource but have the system to continue in case a 2-cycle arises? Or should we require a process to choose randomly among resources
582
K. J. COMPTON
AND
C. RAVISHANKAR
not allocated to it? In either case, the model becomes much more complicated. We must keep track not only of the number of active processes, but also of the number of resources allocated to each active process. In addition to the cases in Sections 4 and 5, we would like to have asymptotic expressions
for system
4 if conditions i = o(j).
like
We would
statistics
when
m = o(j)
and
i = Kj. We would
like to know
m log log m = o(j)
like to solve the general
in Section
can be replaced
case in Section
with
5, not just the case
i = m.
Finally, for
we would
fixed
j.
There
like to know are
some
the variances unpublished
and distributions results
on
of ~ , and P,,,
certain
cases
of
this
problem. In the case j = 1, variance and distribution can be determined. This problem should not be confused with one related to the problem of determining the variance and distribution for the traditional birthday problem. Even though
the mean
pair with
of Tn , is the expected
the same birthday
models
the “street
corner
and asks passers-by
corner
for
number
of people
m day years, variance
birthday their
problem”: birthdays
A person until
needed
behaves stands
a repetition
times of passers-by are exponentially distributed random malized mean 1). In the traditional birthday problem (the
to find
differently.
a
Tm, ~
on a busy street is found.
Arrival
variables (with nor“classroom birthday
problem”), a teacher in a classroom aski students their birthdays until a repetition is found. Arrival times are precisely 1. Clearly, the variance for the street corner birthday problem is greater than for the classroom birthday problem. Donald Knuth (personal communication) has informed us that using techniques asymptotic
in Knuth [1985] one may show that variance in to (4 – m )m /2. Guy Louchard of the University Libre
(personal communication) has informed us that, for street corner birthday problems, the random variable suitably variable. tion)
normalized, Alfredo
converges Viola
has some preliminary
ACKNOWLEDGMENTS.
in distribution
of the
We
University
results
on the variance
would
like
to
both the classroom and for a repeated birthday,
to a Rayleigh of Waterloo
thank
this case is de Bruxelles
distributed
(personal
of ~,,,,
Philippe
for fixed
Flajolet
random
communicaj.
for
many
useful suggestions and discussions. We would also like to thank Yuri Gurevich and Andreas Blass for making a fundamental observation that led to the development of the model in eq. (l). Both authors would like to thank the creators of Maple system. out or checked in Maple.
Most
of the computations
in this paper
were
carried
REFERENCES BIC, L., AND SHAW, A. C. 1988. The Logical Design of Operating System&. Prentice-Hall, En@ewood Cliffs, N.J. CAUCHY, A. L. 1826. EXWCWS de Ma fhematzgue. Chez de Bure Freres, Paris, France. DAVID, F. N., KENDALL. M. G., AND BARTON, D. E. 1966. ,Syrnnletnc Funcfzon and Alhed Tab[e~. Cambridge Unwersity Press, Cambridge. England. FELLER, W. 1971. lntroductum to Probabd@ Theory and IfA Applicatiotu, vol. 2, Wiley, New York. FLA.JOI ET, P., GARDY, D., AND THIMONIER, L. 1988. Probabilistic languages and random allocaLanguages and Programmmg, T. Leplsto and A. Salomaa, eds. Lecture tions. In Aufornakz, Notes m Computer Science, vol. 317. Springer-Verlag, pp. 239-253. FLAIOLE r, P., GRABNER, P. J., KIRSCHENHOPER, P., AND PRODINGER, H. 1992. On Ramanujan’s Q-function. Rapport dc Rechercbe 1760. Institut National de Recherche en Informatique et en Automatique, Rocquencourt, France.
Expected
Deadlock
Time
583
FLAJOLET, P., AND ODLYZKO, A. M. 1990a.
Random mapping statistics. In Adtances
or C~ptol-
J. J. QU@ater and J. Vandewalle, eds. Lecture Notes in Computer Science, vol. 434. Springer-Verlag, New York, pp. 329-354. FLAJOLET,P., AND ODLYZKO, A. M. 1990b. Singularity analysis of generating functions. SIAM J. 00.
Disc. Math. 3, 216-240. GRAHAM, R. L., KNUTH, D. E., AND PATASHNIK, O. 1989. Concrete Mathernadcs. Addison-Wesley, Reading, Mass. HENRICI, P. 1977. Applied and Computational Corfzplex Analyws, vol. 2. Wiley, New York. KNUTH, D. E. 1968. The Art of Computer Programming, vol. 1: Fundamental Algorithm~, 2nd ed. Addison-Wesley, Reading, Mass. KNUTH, D. E. 1973. The Art of Computer Programmmg, vol. 3: Sorting and Searching. AddisonWesley, Reading, Mass. KNUTH, D. E. 1985. An analysis of optimum caching. J. Algorithms 6, 181-199. KNUTH, D. E., AND SCHONHAGE, A. 1978. The expected linearity of a simple equivalence algorithm. Theoret. Comput. Sci. 6, 281–315. LYNCH, J. 1994. Random resource allocation graphs and the probability of deadlock. SL4M 1 Disc. Math. 7, 458-473. MARKUSHEVICH, A. I. 1977. Theory of Functions of a Complex Variable. Chelsea, New York. Revised. (English edition translated and edited by Richard A. Silverman.) RAMANUJAN, S. 1912. Question 294. J. Indian Math. Sot. 4, 151-152. RIORDAN, J., 1968. Combinatorial Identities. Wiley, New York. SLOANE, N. J. A. 1973. Handbook of Integer Sequences. Academic Press, San Diego, Calif. WTTER, J. S., AND FLAJOLET, P. 1990. Analysis of algorithms and data structures. In Handbook of Theoretical Computer Science, vol. A Algorithms and Complexi~, J. van Leeuwen, ed. North Holland, Amsterdam, The Netherlands, pp. 431-524. Academic Press, San Diego, Calif. WILF, H. S. 1990. generatingfanctionology. YAO, A. C.-C. 1976. On the average behavior of set merging algorithms. In Proceedings of the 8th ACM Symposium on Theoiy of Computing (Hershey, Pa., May 3–5). ACM, New York, pp. 19~_195.
RECEIVED JANUARY 1993; REVISED SEPTEMBER 1994; ACCEPTED NOVEMBER 1994 JournalOfthe As~ocmaonfor COmp~tmgM~chmeq,VOI 42,NO 3, Mq 1995