文档介绍:-可编辑修改-
-可编辑修改 -
#include<iostream>usingnamespacestd;
structPCB
{
charName;//进程名
floatTime;//要求运行时间
intLevel;-可编辑修改-
-可编辑修改 -
#include<iostream>usingnamespacestd;
structPCB
{
charName;//进程名
floatTime;//要求运行时间
intLevel;//优先数
boolstate;//状态,1表就绪
PCB*next;//指针
};
voidInit(PCB*head)
{
intnum;
PCB*s,*p;
cout<<"请输入进程数";
cin>>num;
for(inti=0;i<num;i++)
{
p=head;
s=newPCB;
cout<<"请依次输入进程名要求运行时间优先数";
-可编辑修改-
-可编辑修改 -
cin»s->Name»s->Time»s->Level;
s->state=1;
while(p->next)
if(s->Level>p->next->Level)break;
p=p->next;
s->next=p->next;
p->next=s;
else
s->state=0;
II.
cout«"此进程要求运行时间时间不符合要求,不添加入进程列表
intRun(PCB*head)
PCB*cur,*p;
p=head;
-可编辑修改-
-可编辑修改 -
cur=p->next;
p->next=cur->next;
cur->Level--;
cur->Time--;
cout<<"此次执行的进程信息(执行后):进程名";
cout<<cur->Name<<"剩余时间"<<cur->Time<<"优先数"<<cur->Level;
if(cur->Time<=0)
{
cout<<"状态为完成态"<<endl;
deletecur;
}
else
{
cout<<"状态为就绪态"<<endl;
while(p->next)
{
if(cur->Level>p->next->Level)break;
p=p->next;
-可编辑修