时间片轮转法完成进程调度操作系统实验报告剖析Word格式.docx

上传人:b****6 文档编号:22491933 上传时间:2023-02-04 格式:DOCX 页数:9 大小:123.43KB
下载 相关 举报
时间片轮转法完成进程调度操作系统实验报告剖析Word格式.docx_第1页
第1页 / 共9页
时间片轮转法完成进程调度操作系统实验报告剖析Word格式.docx_第2页
第2页 / 共9页
时间片轮转法完成进程调度操作系统实验报告剖析Word格式.docx_第3页
第3页 / 共9页
时间片轮转法完成进程调度操作系统实验报告剖析Word格式.docx_第4页
第4页 / 共9页
时间片轮转法完成进程调度操作系统实验报告剖析Word格式.docx_第5页
第5页 / 共9页
点击查看更多>>
下载资源
资源描述

时间片轮转法完成进程调度操作系统实验报告剖析Word格式.docx

《时间片轮转法完成进程调度操作系统实验报告剖析Word格式.docx》由会员分享,可在线阅读,更多相关《时间片轮转法完成进程调度操作系统实验报告剖析Word格式.docx(9页珍藏版)》请在冰豆网上搜索。

时间片轮转法完成进程调度操作系统实验报告剖析Word格式.docx

【程序代码】

#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();

//运行

【结果截图】

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 医学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1