操作系统实验报告.docx
《操作系统实验报告.docx》由会员分享,可在线阅读,更多相关《操作系统实验报告.docx(98页珍藏版)》请在冰豆网上搜索。
操作系统实验报告
徐州工程学院
管理学院实验报告
实验课程名称:
计算机操作系统
实验地点:
南主楼七楼机房
2014年2月至2014年4月
专业信息管理与信息系统
班级11信管2班
学生姓名xxx
学号
指导老师刘一男
实验报告
实验项目:
分时系统
实验学时:
2
实验日期:
2013-2-28
实验要求:
加深学生对多道系统中进程管理的理解,了解进程的各种状态及其转换过程,分时系统中时间片的设置及进程在时间片开始和结束时的调度过程。
实验内容:
(1)利用程序设计语言模拟分时系统中多个进程按时间片轮转调度算法进行进程调度的过程;
(2)假设有五个进程A,B,C,D,E,它们的到达时间及要求服务的时间分别为:
进程名
A
B
C
D
E
到达时间
0
1
2
3
4
服务时间
4
3
4
2
4
时间片大小为1,利用程序模拟A,B,C,D,E五个进程按时间片轮转的调度及执行过程并计算各进程的周转时间及带权周转时间。
(3)修改时间片大小为2,利用程序模拟A,B,C,D,E五个进程按时间片轮转的调度及执行过程并计算各进程的周转时间及带权周转时间。
(4)修改时间片大小为4,利用程序模拟A,B,C,D,E五个进程按时间片轮转的调度及执行过程并计算各进程的周转时间及带权周转时间。
时间片的大小对计算机的性能产生什么影响?
在时间片轮转算法中,时间片的大小对系统性能有很大的影响,如选择很小的时间片将有利于段作业,因为它能较快地完成,但会频繁地发生中断、进程上下文的切换,从而增加系统的开销,降低了CPU效率;反之,如选择太长的时间片,使得每个进程都能在一个时间片内完成,时间片轮转算法便退化为FCFS算法,无法满足交互式用户的需求。
一个较为可取的大小是,时间片略大于一次典型的交互所需要的时间。
这样可使大多数进程在一个时间片内完成。
源代码:
#include"stdio.h"
#include"stdlib.h"
#include"iostream.h"
#include"cstdlib"
structprocess
{
charname;
intarri_time;//arrivedtime
intserv_time;//serveredtime
inthave_done_time;//已经运行时间
intdone_time;//完成时间
intturn_around_time;//周转时间
floatwei_turn_around_time;//带权周转时间
structprocess*next;
};
inttime=-1;
inttime_slice=4
;//时间片初始值为1
Isempty(structprocess*head)
{
if(head->next==NULL)
returntrue;
elsereturnfalse;
}
voidpushline(structprocess*head,structprocess*rn)
{
if(rn==NULL)
return;
structprocess*x;
x=head;
while(x->next!
=NULL)
{
x=x->next;
}
x->next=rn;
}
voidpopline(structprocess*head,structprocess**x)
{
if(!
Isempty(head))
{
*x=head->next;
head->next=(*x)->next;
(*x)->next=NULL;
}
}
voidisnewcome(structprocess*head,structprocess*readyline)
{
structprocess*x;
if(head->next==NULL)
return;
if(head->next->arri_time==time&&head->next!
=NULL)
{
cout<