网站导航网学 原创论文 原创专题 网站设计 最新系统 原创论文 论文降重 发表论文 论文发表 UI设计定制 论文答辩PPT格式排版 期刊发表 论文专题
返回网学首页
网学原创论文
最新论文 推荐专题 热门论文 论文专题
当前位置: 网学 > 交易代码 > 课程设计 > 正文

操作系统课程设计-模拟时间片轮转法实现处理器调度

论文降重修改服务、格式排版等 获取论文 论文降重及排版 论文发表 相关服务
操作系统课程设计-模拟时间片轮转法实现处理器调度|精品课程网站设计|课程设计网报告总结心得#include #include #include #include class List;class PCB{public: friend class List;private: PCB (char p[],int t){strcpy(pname,p);runnedtime=0;requesttime=t;status='R';next=NULL;} char pname[2]; int runnedtime; int requesttime; char status; PCB* next;};class List{public: List(char p[]="Q1",int t=0){list=new PCB(p,t);pc=list;time=0;} int print(); int append(char p[],int t); void insert(char p[],int t); void run(); void link(); int length();private: PCB *list; PCB *end(); PCB *pc; int time;};int List::length(){ int cnt=0; PCB *pt=list; for(;pt->next!=list;pt->next,cnt++)  ; return cnt;}void List::link(){ if(list!=NULL)  (end())->next=list;}void List::insert(char p[],int t){ PCB *pt=new PCB(p,t); pt->next=list; list=pt;}int List::append(char p[],int t){ PCB *pt=new PCB(p,t); if(list==NULL)      list=pt; else {    (end())->next=pt; } return 1;}PCB *List::end(){ PCB *prv,*pt; for(prv=pt=list;pt;prv=pt,pt=pt->next)  ; return prv;}int List :: print(){ time++; if(list==0)  return 0; PCB *pt=list; cout<<"name  run_time  req_time  state"<pname[0]<pname[1]<<"       ";  cout<runnedtime<<"        ";  cout<requesttime<<"        ";  cout<status<<"    ";   cout<next; } getch(); return 1;}void List:: run(){    for(;pc;) {  PCB *pt=list;  cout<<"********************************************"<pname<runnedtime+=1;     if(pc->runnedtime==pc->requesttime)  {     pc->status='E';     cout<<"******************************************"<pname<<"运行时间已满,退出队列!"<next;       pc=pc->next;     }    else    {     for(;pt->next!=pc;pt=pt->next)     ;     if(pc->next!=NULL)     {           pt->next=pc->next;           pc=pc->next;         }     else     {        pt->next=NULL;        pc=list;     }    }  }     else   {     if(pc->next!=NULL)          pc=pc->next;        else   pc=list;  }     print();  } }void main(){ cout<<"**********************模拟时间片轮转法实现处理器调度************************"<
版权所有 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2020 myeducs.Cn www.myeducs.Cn All Rights Reserved 湘ICP备09003080号 常年法律顾问:王律师