



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




To help you get a sense of my expectations, enclosed are (partial) solutions to three typical exercises. These three exercises illustrate the range of “solution types” you will be expected to produce.
You will note that all the solutions are typeset. I happen to use LATEX for technical typeset- ting; some prefer to use plain TEX. You can use either, or neither, or you can use any other document preparation system you are familiar with — provided it can do a decent job with technical typesetting. If you prefer, you can write your solutions (neatly) by hand. I care much more about the content than the style.
Exercise 1.2.
(a) Modify program ssq1 to output the additional statistics ¯l, ¯q and ¯x. (b) Similar to example 1.2.8, use this program to compute a table of ¯l, ¯q and ¯x for traffic intensities of 0 .6, 0.7, 0.8, 0.9, 1.0, 1.1, and 1.2. (c) Comment on how ¯l, ¯q and ¯x depend on the traffic intensity. (d) Relative to examples 1.2.8 and 1.2.9, if it is decided that ¯q greater than 5 .0 is not acceptable, to d.dd precision what systematic increase in service times would be acceptable?
(a) The modification is based on the equations in theorem 1.2.1 or, equivalently, Little’s equations (see page 1.2.9). In particular, relative to these equations, when program ssq terminates there will be the following correspondence between mathematical quantities and program variables
c ∑n ←→ departure n ∑i=1^ wi^ ←→^ sum.wait n ∑in=1^ di^ ←→^ sum.delay i=1 si^ ←→^ sum.service.
Because ¯l =
( (^) n
cn
) w ¯ =
cn
∑n
i=
wi
with analogous equations for ¯q and ¯x, it follows that the only modification that must be made to program ssq1 to output ¯l, ¯q and ¯x is the addition of the following three printf statements
printf("average nbr in the node .... = ", sum.wait / departure); printf("average nbr in the queue ... = ", sum.delay / departure); printf("utilization ................ = ", sum.service / departure);
(b) Using the data in the file ssq1.dat produces a traffic intensity of ¯s/r¯ ' 0 .721. To change the traffic intensity to a specific value, say ρ, we can multiply each service time by ρ/ 0 .721. At the expense of needing to re-compile each time ρ is changed, the easiest way to accomplish this modification to program ssq1 is to add the line
Exercise 1.2.
Complete the proof of theorem 1.2.1.
The solution to this exercise is based on the proof/derivation of the “wait” equation on page 1.2.9, modified to handle the “delay” and “service” equations.
To derive the delay equation, for each job i = 1, 2 ,... , n define a delay indicator function θi(t) that is 1 when the ith^ job is in the queue and is 0 otherwise
θi(t) =
{ 1 ai < t < bi 0 otherwise.
Then the number in the queue at time t is
q(t) =
∑^ n
i=
θi(t) 0 < t < cn
and so (^) ∫ cn 0
q(t) dt =
∫ (^) cn
0
∑^ n
i=
θi(t) dt =
∑^ n
i=
∫ (^) cn
0
θi(t) dt =
∑^ n
i=
(bi − ai) =
∑^ n
i=
di.
The service equation can be derived in a similar way. Or, as an alternative, note that l(t) = q(t) + x(t) for 0 < t < cn and wi = di + si for 1 = 1, 2 ,... , n so that we can use the wait and delay equations to derive the service equation, as illustrated ∫ (^) cn
0
x(t) dt
∫ (^) cn
0
x(t) dt =
∫ (^) cn
0
(l(t) − q(t)) dt
=
∫ (^) cn
0
l(t) dt −
∫ (^) cn
0
q(t) dt
=
∑^ n
i=
wi −
∑^ n
i=
di
∑^ n
i=
(wi − di)
∑^ n
i=
si.
Exercise 2.1.
For the tiny Lehmer generator defined by g(x) = ax mod 127, find all the full-period mul- tipliers. (a) How many are there? (b) What is the smallest one? (a) Because the prime factorization of m − 1 = 126 is 2 · 32 · 7 and because
(2 − 1)(3 − 1)(7 − 1) 2 · 3 · 7
from theorem 2.1.3 we know that there are 36 full-period multipliers.
(b) Provided the program parameter A is a full-period multiplier, the enclosed program, based on algorithms 2.1.1 and 2.1.2, generates and prints (“finds”) all of the 36 full-period multipliers. (If A is not a full-period multipler the program will produce no output.) By inspection of the output we see that 3 is the smallest full-period multiplier.
*/
#include <stdio.h>
#define M 127 /* for this modulus ... / #define A 3 / 3 is a full-period multiplier */
long g(long x) { return ((A * x) % M); }
long gcd(long a, long b) /* from appendix B, use a > 0 and b > 0 */ { long r = a % b; while (r > 0) { a = b; b = r; r = a % b;