电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

操作系统课程设计 设备管理实现 源代码VIP免费

操作系统课程设计 设备管理实现 源代码_第1页
操作系统课程设计 设备管理实现 源代码_第2页
操作系统课程设计 设备管理实现 源代码_第3页
#include#include"iostream.h"#include"stdlib.h"#include"string.h"structPCB{intid;charname[10];intsize;structPCB*next;};structPCB*running;structPCB*ready;structPCB*blocked;structPCB*q;structPCB*p;intid=1;intsize;charname[10];//////////////////////////////////////////////////////////////////////////////////////structDCT{//设备charname[10];intbusy;PCB*occupied;PCB*waiting;structDCT*next;structCOCT*coct;//上级控制器};structCOCT{//控制器charname[10];intbusy;PCB*occupied;PCB*waiting;structCOCT*next;structCHCT*chct;//控制器的上级通道};structCHCT{//通道charname[10];intbusy;PCB*occupied;PCB*waiting;structCHCT*next;};//////////////////////////////////////////////////////////////////////////////////////structDCT*dcts;structCOCT*cocts;structCHCT*chcts;voidenqueue(intid,char*name,intsize,structPCB*head){structPCB*node=(structPCB*)malloc(sizeof(structPCB));node->next=0;node->id=id;strcpy(node->name,name);node->size=size;structPCB*tmp=head;while(tmp->next!=0)tmp=tmp->next;tmp->next=node;}structPCB*dequeue(structPCB*head){structPCB*tmp=head->next;if(head->next!=0){head->next=head->next->next;tmp->next=0;}return(tmp);}voidcreateProcess(){printf("\nname:");scanf("%s",name);printf("size:");scanf("%d",&size);printf("\n");enqueue(id++,name,size,ready);if(running==0){running=dequeue(ready);}}voidswitchProcess(){if(running!=0&&ready->next!=0){enqueue(running->id,running->name,running->size,ready);running=dequeue(ready);}elseprintf("没有可切换的进程\n");}voidblockProcess(){if(running==0)printf("没有可阻塞的进程\n");else{enqueue(running->id,running->name,running->size,blocked);running=0;if(ready->next==0)printf("没有可执行的进程\n");elserunning=dequeue(ready);}}voidwakeupProcess(){if(blocked->next==0)printf("没有可激活的进程");else{enqueue(blocked->next->id,blocked->next->name,blocked->next->size,ready);dequeue(blocked);if(running==0)running=dequeue(ready);}}voidterminateProcess(){//结束进程if(running==0){printf("没有需要结束的进程\n");}else{running=dequeue(ready);}}voiddisplayProcessstatus(){printf("--------就绪态--------\n");if(ready->next==0)printf("当前没有进程在该状态\n");if(ready->next!=0){q=ready->next;while(ready->next!=0){printf("%s",ready->next->name);printf("%d\n",ready->next->size);ready->next=ready->next->next;}ready->next=q;}printf("--------执行状态--------\n");if(running==0)printf("当前没有进程在该状态\n");if(running!=0){printf("%s",running->name);printf("%d\n",running->size);}printf("--------阻塞状态--------\n");if(blocked->next==0)printf("当前没有进程在该状态\n\n");if(blocked->next!=0){p=blocked->next;while(blocked->next!=0){printf("%s",blocked->next->name);printf("%d\n",blocked->next->size);blocked->next=blocked->next->next;}blocked->next=p;}}//////////////////////////////////////////////////////////////////////////////////structDCT*findDCT(charname[])//设备分配时找到要添加的设备{structDCT*temp=dcts;while(temp->next!=NULL){temp=temp->next;if(strcmp(temp->name,name)==0)returntemp;}returnNULL;}structCHCT*findChannel(charname[]){structCHCT*temp=chcts;while(temp->next!=NULL){temp=temp->next;if(strcmp(temp->name,name)==0)returntemp;}returnNULL;}structCOCT*findController(charname[]){structCOCT*temp=cocts;while(temp->next!=NULL){temp=temp->next;if(strcmp(temp->name,name)==0)returntemp;}returnNULL;}voidaddProcesstoWaiting(structPCB*waiting,structPCB*p)//进入进程等待队列{struct...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

墨香书阁+ 关注
实名认证
内容提供者

热爱教学事业,对互联网知识分享很感兴趣

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部