资源简介
实验(一)多道程序、进程、分时系统模拟
1、 实验目的
加深学生对多道系统中进程管理的理解,了解进程的各种状态及其转换过程,分时系统中时间片的设置及进程在时间片开始和结束时的调度过程。
2、 实验内容
(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五个进程按时间片轮转的调度及执行过程并计算周转时间及带权周转时间。
3、 思考
时间片的大小对计算机的性能产生什么影响?

代码片段和文件信息
#include “stdio.h“
#include “stdlib.h“
#include “iostream.h“
struct process
{
char name;
int arri_time;//arrived time
int serv_time;//servered time
int have_done_time;//已经运行时间
int done_time;//完成时间
int turn_around_time;//周转时间
float wei_turn_around_time;//带权周转时间
struct process * next;
};
int time=-1;
int time_slice=1
;//时间片初始值为1
Isempty(struct process* head)
{
if (head->next==NULL)
return true;
else return false;
}
void pushline(struct process* headstruct process* rn)
{
if (rn==NULL)
return;
struct process* x;
x=head;
while (x->next!=NULL)
{
x=x->next;
}
x->next=rn;
}
void popline(struct process* headstruct process** x)
{
if(!Isempty(head))
{
*x=head->next;
head->next=(*x)->next;
(*x)->next=NULL;
}
}
void isnewcome(struct process* headstruct process* readyline)
{
struct process* x;
if (head->next==NULL)
return;
if (head->next->arri_time==time&&head->next!=NULL)
{
cout< popline(head&x);
pushline(readylinex);
}
}
void main()
{
struct process* head;
struct process* newnode;
struct process* tail;
struct process* readyline;//队列
readyline=(struct process*)malloc(sizeof(process));
readyline->next=NULL;
int i;
struct process* rightnow;
struct process* p;
/*struct process* n;*/
head=(struct process*)malloc(sizeof(process));
if(!head)
{
cout<<“内存分配错误“< }
head->next=NULL;
tail=head;
while (1)
{
newnode=(struct process*)malloc(sizeof(process));
cout<<“请输入进程名“< cin>>newnode->name;
if(newnode->name==‘#‘)
break;
cout<<“请输入进程到达时间“< cin>>newnode->arri_time;
cout<<“请输入进程服务时间“< cin>>newnode->serv_time;
newnode->done_time=0;
newnode->turn_around_time=0;
newnode->wei_turn_around_time=0.0;
newnode->have_done_time=0;
// tail->next=newnode;
newnode->next=NULL;
//tail=newnode;
pushline(headnewnode);
}
p=head->next;
while(p!=NULL)
{
cout<name<<“进程“< p=p->next;
}
ss: while(time<200)
{
time++;
//cout<<“当前TIME“< isnewcome(headreadyline);
if (time!=0)
pushline(readylinerightnow);
i=time_slice;
//cout<<“i=“< while (i!=0)
{
//cout<<“DANG QIANG TIME“< if (i==time_slice)
{
i--;
if(!Isempty(readyline))
{
popline(readyline&rightnow);
rightnow->have_done_time++;
rightnow->done_time=time;
cout<<“run “<name< if (rightnow->have_done_time==rightnow->serv_time)
{
rightnow->turn_around_time=rightnow->done_time-rightnow->arri_time+1;
rightnow->wei_turn_around_time=(float)rightnow->turn_around_time/rightnow->serv_time;
cout<<“********************“<<
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5056 2010-05-25 10:30 分时系统\012.cpp
文件 3365 2010-05-05 21:51 分时系统\012.dsp
文件 512 2010-05-05 21:51 分时系统\012.dsw
文件 41984 2010-05-25 10:33 分时系统\012.ncb
文件 49664 2010-05-25 10:33 分时系统\012.opt
文件 1100 2010-05-25 10:30 分时系统\012.plg
文件 229413 2010-05-25 10:30 分时系统\Debug\012.exe
文件 297568 2010-05-25 10:30 分时系统\Debug\012.ilk
文件 13513 2010-05-25 10:30 分时系统\Debug\012.obj
文件 274512 2010-05-25 10:18 分时系统\Debug\012.pch
文件 549888 2010-05-25 10:30 分时系统\Debug\012.pdb
文件 50176 2010-05-25 10:30 分时系统\Debug\vc60.idb
文件 61440 2010-05-25 10:30 分时系统\Debug\vc60.pdb
文件 51712 2010-04-29 17:31 分时系统\os实验指导.doc
目录 0 2010-05-25 10:30 分时系统\Debug
目录 0 2010-05-25 10:33 分时系统
----------- --------- ---------- ----- ----
1629903 16
- 上一篇:DATA1.MSI
- 下一篇:SJFFCFSHRRN
相关资源
- E4A无障碍跨程序操作类库(带源码、
- 升腾Win终端系统升级方法新版.doc
- Uninstall_Cortana_WINCLIENT.CN.rar
- STM32基于rt_thread操作系统的SDHC卡文件
- msp430F149操作红外接收模块源码
- 操作系统 LRU算法 实验报告 及 程序代
- [免费]车载CE6.0操作系统
- 分页系统模拟实验 操作系统 课程设
- 二叉树基本操作源代码
- 模拟段页式虚拟存储管理中地址转换
- 操作系统实验——虚存管理实验
- 广工操作系统实验
- php 操作INI文件,读取,设置,ini文件
- 广东工业大学操作系统实验四文件系
- Bochs入门教程[操作系统第一步]
- 软件工程文档模板1可行性研究报告
- 三维地形的仿真显示实现了对地图的
- 用矩阵类算法程序和最小二乘法
- 操作系统课程设计完整版
- 一个基于MFC的GridCtrl,提供类似Excel的
- 磁盘调度算法的模拟实现及对比
- 模拟一个文件管理系统
- JS操作本地网页串口源码
- 二级文件系统(操作系统)
- uCOS编译环境建立 BC45 TASM
- usb调试程序 对USB设备进行数据的读写
- Linux 操作系统实验(全)
- 操作系统实验综合设计【附代码】
- 操作系统共享内存实验
- 操作系统循环首次适应算法
评论
共有 条评论