欢迎来到天天文库
浏览记录
ID:32976076
大小:101.12 KB
页数:7页
时间:2019-02-18
《操作系统磁盘驱动实验》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include#includc#include#includetypedefstructdrive{charproName[10];//进程名intcyNum;//柱面号inttraNum;//磁道号intphy_re_Num;//物理记录号structdrive*next;//扌旨纟十}*dm;intinitLink(dm&d){d=(drive*)malloc(sizeof(drive));if(!d)exit(-l);d->next=NULL;return1;intse
2、tProcessor(dm&d){return1;}intdrive_Manage(dm&djnt&local_cyNumjnt&local_traNum,int&local_reNum.char*direction,char*local_proName){inttemp=160;intsignal=0;dmp;dmq;intk=1;p=d->ncxt;if(d->next==NULL)return0;whilc(p!=NULL){signal=1;p=p->next;if(signal==1){temp=160;p=d->next;whilc(p!
3、=NULL){if(p->cyNum==local_cyNum){(local_traNum+(local_traNum+(local_traNum+(local_traNum+(local_traNum+1)・(local_traNumif((p->traNum+1)*(p->phy_re_Num+1)>l)*(local_rcNum+1)&&(p->traNum+1)*(p->phy_rc_Num+1)-l)*(local_reNum+1)<=temp){temp=(p->traNum+1)*(p->phy_re_Num+1)-l)*(local
4、_reNum);q=p;}elseif((p->traNum+1)*(p->phy_re_Num+1)<1)*(local_reNum)&&20*8+(p->traNum+1)*(p->phy_re_Num+1)・l)*(local_reNum+1)<=temp){temp=20*8+(p->traNum+1)*(p->phy_re_Num++l)*(local_reNum+1);q=p;}}p=p->next;else{temp=200;p=d->next;if(!strcmp(direction,,,up,'))while(p!=NULL)if(
5、p->cyNum>local_cyNum){signal=1;}p=p->next;}p=d->next;if(signal==1){whilc(p!=NULL){if(p->cyNum>local_cyNum&&p->cyNum・local_cyNum<=temp){temp=p->cyNum・local_cyNum;q=p;}p=p->next;}}else{//printf("%sn,q->proName);strcpy(direction,Mdownn);while(p!=NULL){if(p->cyNum6、cal_cyNum-p->cyNum<=temp){temp=local_cyNum-p->cyNum;q=p;}p=p->ncxt;}}}elseif(!strcmp(dircction/rdownn)){p=d->next;while(p!=NULL){p=p->ncxt;p=d->next;if(signal==1){whilc(p!=NULL){if(p->cyNumcyNum<=temp){temp=local_cyNum・p->cyNum;q=p;}p=p->next;}}else7、{strcpyCdirection/'up");while(p!=NULL){if(p->cyNum>local_cyNum&&p->cyNum-local_cyNum<=temp){temp=p->cyNum・local_cyNum;q=p;}p=p->ncxt;//登记当前内容local_traNum=q->traNum;locaLcyNum=q->cyNum;local_reNum=q->phy_re_Num;〃将此结点从链表屮移除p=d;while(k)if(k==1)p=p->next;p->next=q->next;q->next=NUL8、L;strcpy(local_proName,q->proName);free(q);return1;int
6、cal_cyNum-p->cyNum<=temp){temp=local_cyNum-p->cyNum;q=p;}p=p->ncxt;}}}elseif(!strcmp(dircction/rdownn)){p=d->next;while(p!=NULL){p=p->ncxt;p=d->next;if(signal==1){whilc(p!=NULL){if(p->cyNumcyNum<=temp){temp=local_cyNum・p->cyNum;q=p;}p=p->next;}}else
7、{strcpyCdirection/'up");while(p!=NULL){if(p->cyNum>local_cyNum&&p->cyNum-local_cyNum<=temp){temp=p->cyNum・local_cyNum;q=p;}p=p->ncxt;//登记当前内容local_traNum=q->traNum;locaLcyNum=q->cyNum;local_reNum=q->phy_re_Num;〃将此结点从链表屮移除p=d;while(k)if(k==1)p=p->next;p->next=q->next;q->next=NUL
8、L;strcpy(local_proName,q->proName);free(q);return1;int
此文档下载收益归作者所有