磁盘调度实验报告Word文档格式.docx

上传人:b****6 文档编号:17439469 上传时间:2022-12-01 格式:DOCX 页数:11 大小:64.80KB
下载 相关 举报
磁盘调度实验报告Word文档格式.docx_第1页
第1页 / 共11页
磁盘调度实验报告Word文档格式.docx_第2页
第2页 / 共11页
磁盘调度实验报告Word文档格式.docx_第3页
第3页 / 共11页
磁盘调度实验报告Word文档格式.docx_第4页
第4页 / 共11页
磁盘调度实验报告Word文档格式.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

磁盘调度实验报告Word文档格式.docx

《磁盘调度实验报告Word文档格式.docx》由会员分享,可在线阅读,更多相关《磁盘调度实验报告Word文档格式.docx(11页珍藏版)》请在冰豆网上搜索。

磁盘调度实验报告Word文档格式.docx

5、“接受请求”进程建立一张“进程请求I/O”表,指出等待访问磁盘的进程要求访问的磁道,表的格式如下:

进程名

要求访问的磁道号

6、“磁盘调度”的功能是查“请求I/O”表,当有等待访问的进程时,按电梯调度算法(SCAN算法)从中选择一个等待访问的进程,按其指定的要求访问磁道。

SCAN算法参考课本第九章。

算法模拟框图略。

7、附图中的“初始化”工作包括:

初始化“请求I/O”表,设置置当前移臂方向;

当前磁道号。

并且假设程序运行前“请求I/O”表中已有若干进程(4~8个)申请访问相应磁道。

四、实验报告:

1、实验题目。

2、程序中用到的数据结构及其说明。

3、打印源程序并附注释。

4、实验结果内容如下:

打印“请求I/O”表,当前磁道号,移臂方向,被选中的进程名和其要求访问的磁道,看是否体现了电梯调度(SCAN)算法。

5、体会与问题。

五、附图:

开始

初始化

磁盘调度

随机数>1/2

继续?

接受请求

输入在[0,1]区间内的随机数

结束

六实验源程序

主函数控制台main.cpp

#include<

iostream.h>

#include"

node.h"

fcfs.h"

#include"

sstf.h"

scan.h"

voidmain()

{

structnode*first=creatlist();

intn=0;

while(n!

=4)

{

cout<

<

"

请输入你的选择:

\n1:

先来先服务(FCFS)\n"

;

2:

最短寻道时间优先(SSTF)\n3:

扫描(SCAN)\n4:

退出\n"

cin>

>

n;

switch(n)

{

case1:

fcfs(first);

break;

case2:

sstf(first);

case3:

scan(first);

case4:

default:

}

}

}

先来先服务FCFS.h

#ifndefFCFS_H

#defineFCFS_H

#include<

math.h>

voidfcfs(structnode*first)

inttotal=0;

structnode*p=first->

next;

intstart=p->

track;

intlast=p->

cout<

该算法扫描磁道的顺序为\n"

while(p)

total+=abs(start-last);

//cout<

abs(start-last)<

endl;

p->

track<

->

p=p->

if(p)

last=start;

start=p->

\n先来先服务总共寻道长度:

total<

先来先服务平均寻道长度:

float(total)/9<

#endif

电梯调度算法scan.h

#ifndefSCAN_H

#defineSCAN_H

structnode*search1(structnode*,structnode*,int);

voiddel1(structnode*,structnode*);

voidscan(structnode*first)

structnode*head=newnode;

head->

next=NULL;

while(p)

structnode*s=newnode;

s->

num=p->

num;

track=p->

insert(head,s);

structnode*p2=head->

structnode*p1=head;

while(head->

next)

while

(1)

cout<

p2->

del1(p1,p2);

p1=search1(head,p2,1);

if(p1==NULL)

{

break;

}

if(p1->

total+=abs(p2->

track-p1->

next->

track);

p2=p1->

p1=search1(head,p2,-1);

if(p1==NULL)

\n扫描(SCAN)一共寻道长度:

扫描(SCAN)平均寻道长度:

double(total)/9<

structnode*search1(structnode*head,structnode*p2,inta)

structnode*q=head->

next,*re=NULL,*q1=head;

inta1=0,a2=0;

if(q)

a1=a*(q->

track-p2->

while(q)

a2=a*(q->

if((a1<

0&

&

a2>

=0)||(0<

=a2&

a2<

=a1))

re=q1;

a1=a2;

q1=q;

q=q->

returnre;

//返回相对当前磁道距离最短的磁道的前一进程要求访问的磁道位置

voiddel1(structnode*p1,structnode*p2)

p1->

next=p2->

最短距离优先调度算法sstf..h

#ifndefSSTF_H

#defineSSTF_H

structnode*search(structnode*,structnode*);

voiddel(structnode*,structnode*);

voidsstf(structnode*first)

while(p2)

del(p1,p2);

p1=search(head,p2);

if(p1->

total+=abs(p2->

p2=p1->

\n最短寻道时间优先一共寻道长度:

最短寻道时间优先平均寻道长度:

structnode*search(structnode*head,structnode*p2)

next,*re=head,*q1=head;

a1=abs(q->

a2=abs(q->

if(a2<

a1)

voiddel(structnode*p1,structnode*p2)

公共节点头信息node.h

#ifndefNODE_H

#defineNODE_H

structnode

intnum;

//进程号

inttrack;

//进程要求访问的磁道号

node*next;

};

structnode*creatlist();

voidinsert(structnode*first,structnode*s);

//插入一个节点(尾插法)

structnode*creatlist()

structnode*first=newnode;

first->

inttrackk[10]={100,55,58,39,18,90,160,150,38,184};

for(inti=0;

i<

10;

i++)

structnode*s;

s=newnode;

num=i;

track=trackk[i];

insert(first,s);

returnfirst;

voidinsert(structnode*first,structnode*s)

structnode*r=first;

structnode*p;

while(r){p=r;

r=r->

p->

next=s;

p=s;

七实验结果

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

当前位置:首页 > 高中教育 > 英语

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

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