操作系统实验 磁盘调度

上传人:第*** 文档编号:31144057 上传时间:2018-02-05 格式:DOC 页数:8 大小:70.50KB
返回 下载 相关 举报
操作系统实验 磁盘调度_第1页
第1页 / 共8页
操作系统实验 磁盘调度_第2页
第2页 / 共8页
操作系统实验 磁盘调度_第3页
第3页 / 共8页
操作系统实验 磁盘调度_第4页
第4页 / 共8页
操作系统实验 磁盘调度_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《操作系统实验 磁盘调度》由会员分享,可在线阅读,更多相关《操作系统实验 磁盘调度(8页珍藏版)》请在金锄头文库上搜索。

1、操作系统实 验 报 告课程名称 操作系统实验 课程编号 0920311实验项目名称 磁盘调度算法学号 年级姓名 专业学生所在学院 软件学院 指导教师 王宏斌实验室名称地点 计算机软件第二实验室 21#2821第十讲 磁盘调度算法一、实验概述1. 实验名称磁盘调度算法2. 实验目的通过学习EOS实现磁盘调度算法的机制,掌握磁盘调度算法执行的条件和时机;观察EOS实现的FCFS、SSTF和SCAN磁盘调度算法,了解常用的磁盘调度算法;编写CSCAN和N-Step-SCAN磁盘调度算法,加深对各种扫描算法的理解。 3. 实验类型验证设计4. 实验内容理解EOS是如何实现磁盘调度算法的;学习EOS是如

2、何测试磁盘调度算法的,并体会这种测试方法的优缺点。二、实验环境操作系统:Windows XP 操作系统集成实验环境软件:Tevation OS Lab编译语言:C 参考书: EOS 操作系统实验教程三、实验过程1.实验指导 P176-3.2 验证先来先服务(FCFS)磁盘调度算法,要求请给出在“输出”窗口中的结果。 * Disk schedule start working *Start Cylinder: 10TID: 31 Cylinder: 8 Offset: 2 -TID: 32 Cylinder: 21 Offset: 13 +TID: 33 Cylinder: 9 Offset:

3、12 -TID: 34 Cylinder: 78 Offset: 69 +TID: 35 Cylinder: 0 Offset: 78 -TID: 36 Cylinder: 41 Offset: 41 +TID: 37 Cylinder: 10 Offset: 31 -TID: 38 Cylinder: 67 Offset: 57 +TID: 39 Cylinder: 12 Offset: 55 -TID: 40 Cylinder: 10 Offset: 2 -Total offset: 360 Transfer times: 10 Average offset: 3622.实验指导 P177

4、-3.3 验证验证最短寻道时间优先(SSTF )磁盘调度算法,要求请给出在“输出”窗口中的结果。 * Disk schedule start working *Start Cylinder: 10TID: 37 Cylinder: 10 Offset: 0 =TID: 40 Cylinder: 10 Offset: 0 =TID: 33 Cylinder: 9 Offset: 1 -TID: 31 Cylinder: 8 Offset: 1 -TID: 39 Cylinder: 12 Offset: 4 +TID: 32 Cylinder: 21 Offset: 9 +TID: 36 Cyli

5、nder: 41 Offset: 20 +TID: 38 Cylinder: 67 Offset: 26 +TID: 34 Cylinder: 78 Offset: 11 +TID: 35 Cylinder: 0 Offset: 78 -Total offset: 150 Transfer times: 10 Average offset: 153.实验指导 P178-3.4 验证 SSTF 算法造成的线程“饥饿”现象,要求请给出在 “输出”窗口中的结果。 * Disk schedule start working *Start Cylinder: 10TID: 37 Cylinder: 10

6、 Offset: 0 =TID: 40 Cylinder: 10 Offset: 0 =TID: 33 Cylinder: 9 Offset: 1 -3TID: 34 Cylinder: 8 Offset: 1 -TID: 35 Cylinder: 11 Offset: 3 +TID: 39 Cylinder: 12 Offset: 1 +TID: 32 Cylinder: 21 Offset: 9 +TID: 36 Cylinder: 41 Offset: 20 +TID: 38 Cylinder: 67 Offset: 26 +TID: 31 Cylinder: 78 Offset: 11

7、 +Total offset: 72 Transfer times: 10 Average offset: 74.实验指导 P179-3.5 验证扫描(SCAN)磁盘调度算法,要求在非饥饿(即实验指导P176-3.2 节中的数据)和饥饿(即实验指导P178-3.4 节中的数据)请给出在“输出”窗口中的结果,并且要求在每次输入两次“ds”命令(注意不要连续输入,要等第一次“ds”命令执行完,再输入第二次“ds” 命令) ,分析结果为什么不同。 非饥饿下第一次:* Disk schedule start working *Start Cylinder: 10TID: 37 Cylinder: 10

8、 Offset: 0 =TID: 40 Cylinder: 10 Offset: 0 =TID: 39 Cylinder: 12 Offset: 2 +TID: 32 Cylinder: 21 Offset: 9 +TID: 36 Cylinder: 41 Offset: 20 +TID: 38 Cylinder: 67 Offset: 26 +TID: 34 Cylinder: 78 Offset: 11 +TID: 33 Cylinder: 9 Offset: 69 -TID: 31 Cylinder: 8 Offset: 1 -TID: 35 Cylinder: 0 Offset: 8

9、-Total offset: 146 Transfer times: 10 Average offset: 14非饥饿下第二次:* Disk schedule start working *Start Cylinder: 10TID: 47 Cylinder: 10 Offset: 0 =TID: 50 Cylinder: 10 Offset: 0 =4TID: 43 Cylinder: 9 Offset: 1 -TID: 41 Cylinder: 8 Offset: 1 -TID: 45 Cylinder: 0 Offset: 8 -TID: 49 Cylinder: 12 Offset:

10、12 +TID: 42 Cylinder: 21 Offset: 9 +TID: 46 Cylinder: 41 Offset: 20 +TID: 48 Cylinder: 67 Offset: 26 +TID: 44 Cylinder: 78 Offset: 11 +Total offset: 88 Transfer times: 10 Average offset: 8饥饿第一次:* Disk schedule start working *Start Cylinder: 10TID: 37 Cylinder: 10 Offset: 0 =TID: 40 Cylinder: 10 Offs

11、et: 0 =TID: 35 Cylinder: 11 Offset: 1 +TID: 39 Cylinder: 12 Offset: 1 +TID: 32 Cylinder: 21 Offset: 9 +TID: 36 Cylinder: 41 Offset: 20 +TID: 38 Cylinder: 67 Offset: 26 +TID: 31 Cylinder: 78 Offset: 11 +TID: 33 Cylinder: 9 Offset: 69 -TID: 34 Cylinder: 8 Offset: 1 -Total offset: 138 Transfer times: 1

12、0 Average offset: 13饥饿第二次:* Disk schedule start working *Start Cylinder: 10TID: 47 Cylinder: 10 Offset: 0 =TID: 50 Cylinder: 10 Offset: 0 =TID: 43 Cylinder: 9 Offset: 1 -TID: 44 Cylinder: 8 Offset: 1 -TID: 45 Cylinder: 11 Offset: 3 +5TID: 49 Cylinder: 12 Offset: 1 +TID: 42 Cylinder: 21 Offset: 9 +TI

13、D: 46 Cylinder: 41 Offset: 20 +TID: 48 Cylinder: 67 Offset: 26 +TID: 41 Cylinder: 78 Offset: 11 +Total offset: 72 Transfer times: 10 Average offset: 7分析:两次 ds 的寻道方向不一样。由于定义了一个布尔类型的全局变量ScanInside,用于表示扫描算法中磁头移动的方向。该变量值为 TRUE 时表示磁头向内移动(磁道号增加);值为 FALSE 时表示磁头向外移动(磁道号减少)。该变量初始化为TRUE,表示 SCAN 算法第一次执行时,磁头向内移

14、动。然后 TRUE 变成 FLASE,所以实验中两次 ds 的结果就发生了变化。5 改写 SCAN 算法算法:PREQUESTIopDiskSchedule(VOID)PLIST_ENTRY pListEntry;PREQUEST pRequest;LONG Offset;ULONG InsideShortestDistance = 0xFFFFFFFF;ULONG OutsideShortestDistance = 0xFFFFFFFF;PREQUEST pNextRequest = NULL;PREQUEST pNextRequestn = NULL;PREQUEST pNextReque

15、stw = NULL;for (pListEntry = RequestListHead.Next;pListEntry != pListEntry = pListEntry-Next) pRequest = CONTAINING_RECORD(pListEntry, REQUEST, ListEntry);Offset = pRequest-Cylinder - CurrentCylinder;6if (0 = Offset) pNextRequest = pRequest;goto RETURN; else if (Offset 0) if (Offset InsideShortestDi

16、stance) InsideShortestDistance = Offset;pNextRequestn = pRequest; else if (Offset 0) if (-Offset OutsideShortestDistance) OutsideShortestDistance = -Offset;pNextRequestw = pRequest;if(ScanInside)if(pNextRequestn!=NULL)pNextRequest=pNextRequestn;elsepNextRequest=pNextRequestw;ScanInside=!ScanInside;elseif(pNextRequestw!=NULL)pNextRequest=pNextRequestw;

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 其它办公文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号