















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!
















the average response time per client
g
p
p
the loss probability of cells
the system throughput
the average number of clients served over a timeperiod
Initialization routine;timing control routine to select the most imminent eventfrom the event list (event clock is updated implicitly){{
event type 1: event routine for event type 1;event type 2: event routine for event type 2;
event type n: event routine for event type n;event type n: event routine for event type n; }
t ti ti
ti
ti
statistics reporting routine;
smpl(m, s)int m=0; /* always 0 */int m 0; /
always 0
char *s;
l
id
d
f
t
f
ti
d
smpl provides seeds for 15 streams for generating randomnumbers. To collect a set of 15 sample values of a particularperformance measure, one can invoke smpl() 15 times:
loop: repeat 15 times
smpl(0, “hw1”); }
l
t
t
t
t
if
th
One can also use stream(1), stream(2), etc. to specify thestream number to be used in a simulation run
r = preempt(fd id, tkn id, pri)
p
p (
, p
int fd_id, tkn_id, pri;=> same as request() except that it will preempt the server if it is busyserving a task with priority < “pri”serving a task with priority <
pri
=> the event record corresponding to the preempted token is removedfrom the event list and a queue entry with the residual time is createdr=0: facility is reservedr=1: facility is busy and the request is blocked in the queue
y
y
q
q
ordered on priorityrelease(fd id tkn id)
create an event with the same
t t
d
t it i
th
t li t
release(fd_id, tkn_id)int fd_id; int tkn_id;=> release the facility and if the queue is not empty, reschedule
bl
k d
i h h
i
event type and put it in the event list
a blocked request to occur with the event occurrence time at NOW+te (te=event time for a blocked task and te=the residualtime for a preempted task)
h d l (
id
k
id)
schedule(event_id, te, tkn_id)int event_id;real te; /* time interval relative to the current time */
int tkn_id;=> schedule the event with id “event_id” to occur at NOW+te=> this essentially inserts an event record with the event occurrence
this essentially inserts an event record with the event occurrence time NOW+te into the event list=> part of the information in the event record is event_id, tkn_id
d h
i
and the event occurrence time NOW+teExample: schedule(2, 0.0, token_id)
p
=> schedule event type #2 associated with token id “token_id” tooccur NOW
cancel(event_id)int event_id;=> search the event list and remove the first event with the event=> search the event list and remove the first event with the eventnumber = event_id
t = real time()t = real time()=> return the current simulation clock value=> real is a predefined type; it is the same as double in C
n= int inq(fd);=> returning # of tokens currently in queue (not including the onesin service)in service)r = int status(fd)
f
ili
i
f
f
ili
i
b
=> r=0: facility is free; r=1: facility is busyu = real U(fd)
=> mean # of tokens in servicen = real Lq(fd)n = real Lq(fd)=> mean # of tokens in queue excluding the ones in serviceb
l B(fd)
b = real B(fd)=> mean busy period = accumulated busy time/release counts
trace(n)int n;
=> generate trace messages when a facility is defined, requested, orreleased, or whenever an event is scheduled or causedn=0: trace is offn=1; free-running, i.e., trace messages are generated continuouslyn=2: screen by screen running (press any key to resume tracing)n=2: screen by screen running (press any key to resume tracing)n=3: message by message running (press any key to resume)
M/M/1 smpl program
#i
l d
“
l h”
#include “smpl.h”main(){ real Ta=200 Ts=
te=200000;
case 2: /* request server */
if (request(server, customer,0)==0)
h d l (
l(T )
)
real Ta=200, Ts=100, te=200000;int customer=1, event, server;smpl(0, “M/M/1 Queue”);server = facility(“server”,1);
schedule(3, expntl(Ts), customer);break;
case 3: /* completion */
release(server customer);
server
facility( server ,1);
schedule(1, 0.0, customer);while (time()< te){
release(server, customer);break;
}
{
cause(&event, &customer);switch(event){
} } report();}
case 1: /* arrival */
schedule(2,0.0, customer);schedule(1, expntl(Ta), customer);b
k
}
17
break;
1
2
N
α
/2;N-
2
2
i (
i^
) 2
m
m
samples to
samples to
generate Y
1
p
generate Y
2
i^