时间片轮法完成进程调度操作系统实验报告文档格式.docx
- 文档编号:5936434
- 上传时间:2023-05-05
- 格式:DOCX
- 页数:9
- 大小:123.42KB
时间片轮法完成进程调度操作系统实验报告文档格式.docx
《时间片轮法完成进程调度操作系统实验报告文档格式.docx》由会员分享,可在线阅读,更多相关《时间片轮法完成进程调度操作系统实验报告文档格式.docx(9页珍藏版)》请在冰点文库上搜索。
【程序代码】
#include"
stdio.h"
#include"
stdlib.h"
structPCB
{
intpid;
//进程标识符
intrr;
//已运行时间
inttime;
//进程要求运行时间
charsta;
//进程的状态
structPCB*next;
//链接指针
};
structPCBpcb1,pcb2,pcb3,pcb4,pcb5,*tail,*head,*rp;
init()
inti,time;
pcb1.pid=1;
pcb2.pid=2;
pcb3.pid=3;
pcb4.pid=4;
pcb5.pid=5;
pcb1.rr=pcb2.rr=pcb3.rr=pcb4.rr=pcb5.rr=0;
pcb1.sta=pcb2.sta=pcb3.sta=pcb4.sta=pcb5.sta='
w'
;
printf("
请输入时间片p1需要运行的时间:
"
);
scanf("
%d"
&
time);
pcb1.time=time;
请输入时间片p2需要运行的时间:
pcb2.time=time;
请输入时间片p3需要运行的时间:
pcb3.time=time;
请输入时间片p4需要运行的时间:
pcb4.time=time;
请输入时间片p5需要运行的时间:
pcb5.time=time;
pcb1.next=&
pcb2;
pcb2.next=&
pcb3;
pcb3.next=&
pcb4;
pcb4.next=&
pcb5;
pcb5.next=&
pcb1;
head=&
tail=&
}
voidprintf1()
+---------------|---------------|---------------|---------------+\n"
|\tpid\t|\trr\t|\ttime\t|\tSTA\t|\n"
|---------------|---------------|---------------|---------------|\n"
printf2()
processesp%drunning\n"
head->
pid);
printf1();
|\t%d\t|\t%d\t|\t%d\t|\t%c\t|\n"
pid,head->
rr,head->
time,head->
sta);
rp=head;
while(rp!
=tail)
{
rp=rp->
next;
rp->
pid,rp->
rr,rp->
time,rp->
}
operation()
{
intflag=1;
while(flag<
=5)
{
head->
rr++;
if((head->
rr==head->
time)||(head->
time==0))
tail->
sta='
f'
printf2();
head=head->
next=head;
flag++;
}
else
r'
tail=head;
voidmain()
init();
//初始化
thisisthebeginstate:
\n"
//显示初始状态
operation();
//运行
【结果截图】
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 时间 片轮法 完成 进程 调度 操作系统 实验 报告