为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

时间片轮转调度

2017-11-10 7页 doc 19KB 18阅读

用户头像

is_281650

暂无简介

举报
时间片轮转调度时间片轮转调度 #include #include #include #include typedef struct node { char name[10]; int prio; int round; int cputime; int needtime; int count; char state; struct node *next; }PCB; PCB *finish,*ready,*tail,*run; //?ÓÁÐÖ?Õë int N; //?ø?ÌÊý void first...
时间片轮转调度
时间片轮转调度 #include #include #include #include typedef struct node { char name[10]; int prio; int round; int cputime; int needtime; int count; char state; struct node *next; }PCB; PCB *finish,*ready,*tail,*run; //?ÓÁÐÖ?Õë int N; //?ø?ÌÊý void firstin() { run=ready; //?ÍÐ??ÓÁÐÍ?Ö?Õë??Öµ?øÔËÐÐÍ?Ö?Õë run->state='R'; //?ø?Ì×?Ì??äΪÔËÐÐÌ?] ready=ready->next; //?ÍÐ??ÓÁÐÍ?Ö?ÕëºóÒƵ?ÏÂÒ??ø?Ì } //Êä?ö?êÌâº?Êý void prt1(char a) { if(toupper(a)=='P') //ÓÅÏÈ???? cout<<" "<name<<" "<cputime<<" "<needtime<<" "<< q->round<<" "<state<next; } p=finish; //Êä?öÍê?É?ÓÁеÄPCB while(p!=NULL) { prt2(algo,p); p=p->next; } getchar(); //??×?ÈÎÒâ?ü?ÌÐø } //Ê??äÆ?ÂÖתµÄ?åÈëËã?? void insert(PCB *q) { PCB *p1,*s,*r; s=q; //?ý?åÈëµÄPCBÖ?Õë p1=ready; //?ÍÐ??ÓÁÐÍ?Ö?Õë r=p1; //*r×öplµÄÇ?ÇýÖ?Õë while(p1!=NULL) if(p1->round<=s->round) { r=p1; p1=p1->next; } if(r!=p1) { r->next=s; s->next=p1; } else { s->next=p1; //?ñÔò?åÈëÔÚ?ÍÐ??ÓÁеÄÍ? ready=s; } } //ÓÅÏÈ???????õ void create(char alg) { PCB *p; int i,time; char na[10]; ready=NULL; finish=NULL; run=NULL; cout<<"ÊäÈë?ø?ÌÃû??ÆäÐèÒªÔËÐеÄÊ??ä?º"<>na; cin>>time; strcpy(p->name,na); p->cputime=0; p->needtime=time; p->state='W'; p->round=0; if(ready!=NULL) insert(p); else { p->next=ready; ready=p; } cout<<"ÊäÈë?ø?ÌÃû??ÆäÐèÒªÔËÐеÄÊ??ä?º"<next; run->state='R'; } void timeslicecycle(char alg) { while(run!=NULL) { run->cputime=run->cputime+8; run->needtime=run->needtime-8; run->round=run->round+8; if(run->needtime<=0) { run->next=finish; finish=run; run->state='F'; run=NULL; if(ready!=NULL) firstin(); } else { run->state='W'; insert(run); firstin(); } prt(alg); } } //Ö?º?Êý void main() { char algo='P'; //Ëã???ê?Ç cout<<"ÊäÈë?ø?̵Ä?öÊý?º"; cin>>N; //ÊäÈë?ø?ÌÊý create(algo); //?????ø?Ì timeslicecycle(algo); //ÓÅÏÈ????µ??È } //main()
/
本文档为【时间片轮转调度】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索