操作标准系统—河海大学文天学院 下载本文

\进程的状态\ while(p->next) {

p=p->next;

cout<<\ \ \ \ \ cout<

m=head->next; if(m->time==0) {

cout<<\进程已经运行完毕,要从链表中删除<next=head->next->next; //将该结点从链表中删除 } else {

head->next=m->next;//对头结点进行重新插入 insert(head,m); }

cout<<\ }

void create(plist &head,int n)//表示链表的长度是可变的

{ int i; pcb *p; for(i=0;i

p=(plist)malloc(sizeof(pcb));

cout<<\请输入第\个进程名:(字符型)\优先级:(整型) \运行时间:(整型) \ cin>>p->id>>p->prior>>p->time;

p->state='r'; //初始的转台全部为r insert(head,p); //将结点插入到合理的位置 } }

void yunxing(plist &head)//对头结点进行的操作 { pcb *m;

cout<<\开始进程调度\ cout<

while(head->next!=NULL) {

m=head->next;

cout<<\进程\被调度,时间数和优先级都减1。\

m->prior=m->prior-1; m->time=m->time-1;

if(m->time==0) //如果头结点已经运行完,将状态改为e head->next->state='e'; showjincheng(head); } }

void main() {

clock_t start,finish; double shijian;

int a; //进程数 int b; //是否确认

do //确认用户的选择,如果输入错误,可以重新输入 {

do //控制进程的数目在合理的范围内 {

system(\

cout<

cout<

cout<>a; if(a>=10||a<0) { if(a>=10)

cout<<\您所创建的进程数不能大于10,请重新输入\else

cout<<\您所创建的进程数不能为负数,请重新输入\ }

} while (a>=10||a<0);

cout<<\您所创建的进程数为\

cout<<\确认请按1,重新输入进程数请按0\ cin>>b; if(b==0) {

system(\

cout<<\请重新输入您所创建的进程的数目\ cin>>a;