嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 1 元微信扫码支付:1 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
#include<iostream.h>
#include<stdlib.h>
#include<conio.h>
struct MES{
int sender;
int size,text;
MES *next;
} aa;
struct PCB{
int id;
int priority;
int nextwr;
int ir;
MES *mq;
char status;
} p[4];
struct semaphore{
int value;
int firstwr;
char *name;
int no;
} sem1,sem2;
int savearea[4][4],s[4][3];
int exe,I,addr,s1,s2,c1,c2,c3;
int R,T,W,C,seed,in=1;
int (*pr[4])(int);
void more();
void create(int k)
{int i;
cout<<"Input the priority of process "<<k<<" : ";
more();
cin>>i;
p[k].id=k;
p[k].ir=0;
p[k].priority=i;
p[k].status='R';
p[k].nextwr=R;
R=k;
cout<<"process "<<k<<" is ready \n";
more();
}
float random()
{
int m;
if(seed<0) m=-seed;
else m=seed;
seed=(25173 * seed 13849) % 65536;
return (m / 32767.0);
}
void more()
{ in ;
if(in%24==0)
{cout<<" ";
getch();cout<<endl;}
}
int time(int i)
{ float x=random();
switch(i)
{case 1:if(x>=0.33){cout<<"time out.\n";more();return 1;}return 0;
case 2:if(x>=0.66||x<0.33) {cout<<"Time out.\n";more();return 1;} return 0;
case 3:if(x<0.66){cout<<"time out.\n"; more();return 1;}return 0;
}return 0;
}
void send(int receiver,MES q)
{ MES *t,*m=new MES;
m->sender=exe;
m->size=q.size;
m->text=q.text;
m->next=0;
if(p[receiver].mq==0) p[receiver].mq=m;
else {t=p[receiver].mq;
while(t->next) t=t->next;
t->next=m;
}
cout<<"process "<<exe<<" sends a message to process "<<receiver<<"\n";
more();
}
......