操作系统-进程调度实验Word文档格式.docx
- 文档编号:14624955
- 上传时间:2022-10-23
- 格式:DOCX
- 页数:21
- 大小:387.06KB
操作系统-进程调度实验Word文档格式.docx
《操作系统-进程调度实验Word文档格式.docx》由会员分享,可在线阅读,更多相关《操作系统-进程调度实验Word文档格式.docx(21页珍藏版)》请在冰豆网上搜索。
,t);
______________________\n"
);
进程名\t运行状态\t运行次数\t还需要运行次数\n"
if(RUN!
=NULL)
{
printf("
%s\t运行\t%d\t%d\n"
RUN->
name,RUN->
cputime,RUN->
needtime);
}
else
printf("
*运行状态为空\n"
p=READY;
if(p!
while(p!
{
printf("
%s\t就绪\t%d\t%d\n"
p->
name,p->
cputime,p->
p=p->
next;
}
*就绪队列为空\n"
p=FINSH;
if(p!
while(p!
{
//printf("
进程名字为:
%s\n"
name);
%s\t完成\t%d\t%d\n"
p=p->
}
}
else
*完成队列为空\n"
getchar();
}
PCB*CPCBLINK()/*建立就绪队列*/
{
建立就绪队列\n\n"
inti,n,nt,pr;
PCB*p,*q,*head;
n=0;
while
(1)
printf("
请输入进程的个数(有效范围1-100):
"
scanf("
%d"
&
n);
\n"
if(n>
=1&
&
n<
=100)
break;
else
printf("
输入有误。
请重新输入!
getchar();
head=(structpcb*)malloc(sizeof(structpcb));
输入第1个进程的名称:
scanf("
%s"
head->
需要的运行时间:
scanf("
nt);
if(nt>
0)
break;
else
{
printf("
输入无效,重新输入!
getchar();
}
head->
needtime=nt;
优先数:
pr);
prio=pr;
head->
cputime=0;
/*进程已获得的运行时间*/
next=NULL;
q=head;
for(i=1;
i<
n;
i++)
printf("
p=(structpcb*)malloc(sizeof(structpcb));
printf("
输入第%d进程的名称:
i+1);
scanf("
p->
p->
q->
next=p;
q=p;
RTAIL=q;
returnhead;
voidJXDLPX()/*就绪队列按优先级从大到小排序*/
PCB*p,*q,*t;
chars[10];
intL=0,ct,pr,nt;
p=READY;
t=(structpcb*)malloc(sizeof(structpcb));
while(p->
next!
{
L=0;
q=p->
t=p;
while(q!
if(t->
prio<
q->
prio)
{
t=q;
L=1;
/*表示有比它优先级大的进程*/
}
q=q->
if(L==1)
strcpy(s,t->
ct=t->
cputime;
pr=t->
prio;
nt=t->
needtime;
q=p->
while(strcmp(q->
name,s)!
=0)
q=q->
strcpy(q->
q->
cputime=p->
q->
prio=p->
needtime=p->
strcpy(p->
name,s);
p->
cputime=ct;
p->
p=p->
}
voidYXS()/*调用优先数调度算法*/
intt=0,nt,ct,pr;
您选择的是:
优先级调度算法\n"
READY=CPCBLINK();
/*建立就绪队列*/
p=(structpcb*)malloc(sizeof(structpcb));
while(READY!
JXDLPX();
/*就绪队列按优先级从大到小排序*/
p=READY;
READY=READY->
pr=p->
pr=pr-3;
/*运行1次进程优先级缩小3*/
nt=p->
nt=nt-1;
ct=p->
ct=ct+1;
RUN=p;
PRINTLINK(t);
/*输出3个队列*/
if(RUN->
needtime<
=0)/*若运行结束进入完成队列*/
{
if(FINSH==NULL)/*第1次进入完成队列*/
{
FINSH=p;
FTAIL=p;
}
else
FTAIL->
FTAIL=FTAIL->
}
RUN=NULL;
else/*若运行没结束进入就绪队列*/
if(READY==NULL)/*当就绪队列为空*/
{
READY=p;
RTAIL=p;
}
else
RTAIL->
RTAIL=p;
}
t++;
voidSJP()/*调用时间片循环轮转算法*/
时间片循环轮转调度算法\n"
intt=0,nt,ct;
nt=nt-2;
if(nt<
nt=0;
ct=ct+2;
RUN=NULL;
else/*若运行没结束进入就绪队列*/
/*主程序*/
intmain()
{
intN;
RUN=(structpcb*)malloc(sizeof(structpcb));
while
(1)
RUN=NULL;
READY=NULL;
RTAIL=NULL;
FINSH=NULL;
FTAIL=NULL;
========
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 操作系统 进程 调度 实验
![提示](https://static.bdocx.com/images/bang_tan.gif)