📄 md1 fcfs.c
字号:
#include "smpl.h"
main ()
{
float Tav=3.125,Tad=0.78125,Ts=0.125,te=200000.0,spanv[200000],spand[30000],wsd=0.0, wsv=0.0;
int countd=0,countv=0,id=0,iv=0,i=0,customer,customerv=1,customerd=2,event,server;
smpl(1, "m/d/1 modle fcfs");
server=facility("server", 1);
schedule(1, expntl(Tav), customerv);
schedule(1, expntl(Tad), customerd);
while (time()<te)
{
cause(&event, &customer);
switch(event)
{
case 1:
schedule(2, 0.0, customer);
if (customer==customerv)
{
spanv[iv++]=time();
schedule(1, expntl(Tav), customer);
}
else
{
spand[id++]=time();
schedule(1, expntl(Tad), customer);
}
break;
case 2:
if (request(server, customer, 0)==0)
{
schedule(3, Ts, customer);
}
break;
case 3:
if (customer==customerv)
{
spanv[countv]=time()-spanv[countv];
countv++;
}
else
{
spand[countd]=time()-spand[countd];
countd++;
}
release(server, customer);
break;
default:
break;
}
}
report();
for(i=0;i<=countv-3;i++)
{
wsv=wsv+spanv[i];
}
printf("\nVoice Ws=%f\n\n",wsv/(countv-2));
for(i=0;i<=countd-3;i++)
{
wsd=wsd+spand[i];
}
printf("Data Ws=%f\n\n",wsd/(countd-2));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -