logo资料库

操作系统仿真程序设计代码.doc

第1页 / 共12页
第2页 / 共12页
第3页 / 共12页
第4页 / 共12页
第5页 / 共12页
第6页 / 共12页
第7页 / 共12页
第8页 / 共12页
资料共12页,剩余部分请下载后查看
附录源代码
附录源代码 #include #include #include #include using namespace std; void delay(int a)//延时函数 { for(int i=0;i
string name; }; struct NAME { string name; }; int main() { srand(time(0)); NAME Name[20]; pcb programer[20]; ReadyState ready[100]; BlockedState block[20]; string state[3]={"阻塞","就绪","运行"}; int n=0;int p=0;int q=0;int m=0;int y=0; int readypno[20];int blockpno[20]; i: cout<<"请选择要执行的功能:"<>s; if(s==1)//显示当前进程 { cout<<"当前进程级状态:"<
programer[n].pid=1234+rand()%49; programer[n].ppno=9+rand()%22; programer[n].pts=rand()%7+rand()%8+rand()%11+3; programer[n].pruntime=0; programer[n].BREAK=""; programer[n].waittimes=0; programer[n].waittime=0; while(n>0) {for(int k=0;k>replace1; string replace2; for(int i=0;i
if(programer[i].state==state[2]) replace2=programer[i].name; for(int k=0;k运行 for(int j=0;j运行 for(int j=0;j
else if(s==4)//进程状态转换 { cout<<"请从新创建的进程中选择要转换的进程。"<>replace; cout<<"需转换的状态:"<>State; for(int i=0;i就绪 if(programer[i].name==replace&&programer[i].state==state[2]&&State==state[1]) { paixu(readypno,m); for(int x=0;x阻塞 if(programer[i].name==replace&&programer[i].state==state[2]&&State==state[0]) { paixu(readypno,m); for(int x=0;x阻塞 if(programer[i].name==replace&&programer[i].state==state[1]&&State==state[0]) { } programer[i].state=state[0]; programer[i].ppno=0; break; for(int i=0;i运行 /剥夺式 if(programer[i].name==replace&&programer[i].state==state[1]&&State==state[2]) { programer[i].state==state[2]; programer[i].ppno=0; for(int j=0;j
if(programer[j].state==state[2]) {programer[j].state==state[1]; readypno[m]=programer[j].ppno; m++; break; } break; } for(int i=0;i就绪 if(programer[i].name==replace&&programer[i].state==state[0]&&State==state[1]) { } programer[i].state=state[1]; readypno[m]=programer[i].ppno; m++; break; for(int i=0;i运行 if(programer[i].name==replace&&programer[i].state==state[0]&&State==state[2]) { } programer[i].state=state[1]; readypno[m]=programer[i].ppno; m++; break; cout<<"映象名称"<<" for(int i=0;i
if(programer[i].state==state[2]) while(programer[i].pts>=0) { cout<<"映象名称"<<" "<<"进程时间片"<
name=programer[i].name; for(int i=0;i0) { cout<<"映象名称"<<" "<<"进程时间片"<=0) { cout<<"映象名称"<<" "<<"进程时间片"<
分享到:
收藏