2022年操作系统设备管理实验代码 .pdf
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《2022年操作系统设备管理实验代码 .pdf》由会员分享,可在线阅读,更多相关《2022年操作系统设备管理实验代码 .pdf(17页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、#include using namespace std; / typedef struct node char name10; char devname10; struct node *next; PCB;/ 进程PCB * run;/执行队列/ typedef struct Node char identify10;/标识int state;/设备状态PCB *blocking;/阻塞队列指针CHCT;/ 通道控制表CHCT * CH1, * CH2; / typedef struct NOde char identify10;/标识int state;/设备状态CHCT * chct;/
2、CHCT PCB *blocking;/阻塞队列指针struct NOde *next; COCT;/ 控制器控制表COCT * cohead; typedef struct NODe char identify10;/标识char type;/设备类型int state;/设备状态int times;/重复执行次数PCB *blocking;/阻塞队列指针COCT * coct;/COCT DCT;/ 设备控制表typedef struct NODE char type;/类别char identify10;/标识DCT * dct;/DCT / 驱动入口地址struct NODE *nex
3、t; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 17 页 - - - - - - - - - SDT; / 系统设备表SDT * head; SDT * checkdel; void Init() PCB * ch1block,* ch2block,* co1block,* co2block,* co3block,* d1block,* d2block,* d3block,* d4block; COCT * CO1,* CO2,* CO3; DCT *d1,*d2,
4、*d3,*d4; SDT *s1,*s2,*s3,*s4; /= run=(PCB *)malloc(sizeof(PCB); run-next=NULL; CH1=(CHCT *)malloc(sizeof(CHCT); CH2=(CHCT *)malloc(sizeof(CHCT); strcpy(CH1-identify,ch1); strcpy(CH2-identify,ch2); CH1-state=0; CH2-state=0; ch1block=(PCB *)malloc(sizeof(PCB); ch1block-next=NULL; ch2block=(PCB *)mallo
5、c(sizeof(PCB); ch2block-next=NULL; CH1-blocking=ch1block; CH2-blocking=ch2block; cohead=(COCT *)malloc(sizeof(COCT); cohead-next=NULL; CO1=(COCT *)malloc(sizeof(COCT); cohead-next=CO1; CO1-next=NULL; CO2=(COCT *)malloc(sizeof(COCT); CO1-next=CO2; CO2-next=NULL; CO3=(COCT *)malloc(sizeof(COCT); CO2-n
6、ext=CO3; CO3-next=NULL; CO1-state=0; CO2-state=0; CO3-state=0; co1block=(PCB *)malloc(sizeof(PCB); co1block-next=NULL; co2block=(PCB *)malloc(sizeof(PCB); co2block-next=NULL; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 17 页 - - - - - - - - - co3block=(PCB *)
7、malloc(sizeof(PCB); co3block-next=NULL; strcpy(CO1-identify,co1); strcpy(CO2-identify,co2); strcpy(CO3-identify,co3); CO1-chct=CH1; CO2-chct=CH1; CO3-chct=CH2; CO1-blocking=co1block; CO2-blocking=co2block; CO3-blocking=co3block; /= d1block=(PCB *)malloc(sizeof(PCB); d2block=(PCB *)malloc(sizeof(PCB)
8、; d3block=(PCB *)malloc(sizeof(PCB); d4block=(PCB *)malloc(sizeof(PCB); d1block-next=NULL; d2block-next=NULL; d3block-next=NULL; d4block-next=NULL; d1=(DCT *)malloc(sizeof(DCT); strcpy(d1-identify,P); d2=(DCT *)malloc(sizeof(DCT); strcpy(d2-identify,T); d3=(DCT *)malloc(sizeof(DCT); strcpy(d3-identi
9、fy,K); d4=(DCT *)malloc(sizeof(DCT); strcpy(d4-identify,M); d1-coct=CO1; d2-coct=CO2; d3-coct=CO3; d4-coct=CO3; d1-state=0; d2-state=0; d3-state=0; d4-state=0; d1-type=o; d2-type=o; d3-type=i; d4-type=i; d1-blocking=d1block; d2-blocking=d2block; d3-blocking=d3block; d4-blocking=d4block; 名师资料总结 - - -
10、精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 17 页 - - - - - - - - - /= head=(SDT *)malloc(sizeof(SDT); head-next=NULL; s1=(SDT *)malloc(sizeof(SDT); s2=(SDT *)malloc(sizeof(SDT); s3=(SDT *)malloc(sizeof(SDT); s4=(SDT *)malloc(sizeof(SDT); head-next=s1; s1-next=s2; s2-nex
11、t=s3; s3-next=s4; s4-next=NULL; s1-dct=d1; s2-dct=d2; s3-dct=d3; s4-dct=d4; strcpy(s1-identify,P); strcpy(s2-identify,T); strcpy(s3-identify,K); strcpy(s4-identify,M); s1-type=o; s2-type=o; s3-type=i; s4-type=i; /test SDT *temp=head-next; /= / 添加设备时候,添加新控制器,把控制器加到最后void Addcotrol (COCT *temp) COCT *
12、cotemp=cohead; while(cotemp-next!=NULL) cotemp=cotemp-next; cotemp-next=temp; temp-next=NULL; / 查看所有控制器,选择所要连接的控制器void Showallco() COCT *temp=cohead-next; while(temp!=NULL) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 17 页 - - - - - - - - - coutidentifynext;
13、coutnext; while(temp!=NULL) if(!strcmp(temp-identify,a) return temp; temp=temp-next; return temp; / 删除设备时候,判断是不是同时删除控制器, 等于 1 删, 0 不删int sf_deleteco(char a,char b) SDT *temp; temp=head-next; while(temp!=NULL) if(strcmp(temp-identify,a)&(!strcmp(temp-dct-coct-identify,b) return 0; temp=temp-next; ret
14、urn 1; / 删除设备的时候同时删除控制器void Deletecotrol(COCT *te) COCT * temp=cohead; while(temp-next!=te) temp=temp-next; temp-next=te-next; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 17 页 - - - - - - - - - delete(te); / 添加设备,查找设备是不是已经存在int sf_exist(char a) SDT *temp; if
15、(head-next=NULL) return 0; else temp=head-next; while(temp!=NULL) if(!strcmp(a,temp-identify) checkdel=temp; return 1; temp=temp-next; return 0; / 申请设备时候,如果忙,将设备挂到等待队列void Addwaitpcb(PCB * p1,PCB * p2) PCB *temp=p1; while(temp-next!=NULL) temp=temp-next; temp-next=p2; p2-next=NULL; / 回收设备时候,对PCB的操作v
16、oid Deletepcb(char a) PCB * temp2=run-next,* temp=run; while(temp2!=NULL) if(!strcmp(temp2-devname,a) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 17 页 - - - - - - - - - temp-next=temp2-next; delete(temp2); break; temp=temp2; temp2=temp-next; / 判断等待队列是不是空int
17、sf_pcbnull(PCB *temp) if(temp-next=NULL) return 0; else return 1; / 查看所有设备状态void Showmenu() PCB * ptemp=run-next; SDT * temp=head-next; DCT * dtemp; COCT * cotemp; CHCT * chtemp; coutSDT i/o COCT CHCTdct; cotemp=dtemp-coct; chtemp=cotemp-chct; coutidentifystatettypetidentifystate tidentifystatenext;
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年操作系统设备管理实验代码 2022 操作系统 设备管理 实验 代码
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内