下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、操作系统实验报告课程名称操作系统实验课程编号0920311实验项目名称磁盘调度算法学号年级专业学生所在学院软件学院指导教师王宏斌实验室名称地点计算机软件第二实验室 21#282文档第十讲 磁盘调度算法一、实验概述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: 12 -TID: 34
3、 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: 362实验指导P177-3.3验证验证最短寻道时间
4、优先( SSTF)磁盘调度算法,要求请给出在“输出”窗口中的结果。* Disk schedule start worki ng *Start Cyli nder: 10TID: 37 Cyli nder: 10 Offset: 0 =TID: 40 Cyli nder: 10 Offset: 0 =TID: 33 Cylinder: 9 Offset: 1 -TID: 31 Cylinder: 8 Offset: 1 -TID: 39 Cyli nder: 12 Offset: 4 +TID: 32 Cylinder: 21 Offset: 9 +TID: 36 Cylinder: 41 Of
5、fset: 20 +TID: 38 Cylinder: 67 Offset: 26 +TID: 34 Cylinder: 78 Offset: 11 +TID: 35 Cylinder: 0 Offset: 78 -Total offset: 150 Tran sfer times: 10 Average offset: 153实验指导P178-3.4验证SSTF算法造成的线程“饥饿”现象,要求请给出在“输出 窗口中的结果。* Disk schedule start worki ng *Start Cyli nder: 10TID: 37 Cyli nder: 10 Offset: 0 =TI
6、D: 40 Cyli nder: 10 Offset: 0 =TID: 33 Cylinder: 9 Offset: 1 -TID: 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 +Total offset
7、: 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 Offse
8、t: 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 -Total
9、 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 =TID: 43 Cylinder: 9 Offset: 1 -TID: 41 Cylinder: 8 Offset: 1 -TID: 45 Cylinder: 0 Offset: 8 -TID: 49 Cylinder: 12 Offset: 12 +TID
10、: 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 Offset: 0
11、=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: Transfer times: 10 Average
12、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 +TID: 49 Cylinder: 12 Offset: 1 +TID: 42 Cylinder: 21 Offset: 9 +TID: 46 Cyli
13、nder: 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 pNextRequestw =
15、NULL;for (pListEntry = RequestListHead.Next; pListEntry != &RequestListHead; pListEntry = pListEntry->Next) pRequest = CONTAINING_RECORD(pListEntry, REQUEST, ListEntry); Offset = pRequest->Cylinder - CurrentCylinder;if (0 = Offset) pNextRequest = pRequest;goto RETURN; else if (Offset >
16、0) if (Offset < InsideShortestDistance) InsideShortestDistance = Offset; pNextRequestn = pRequest; else if (Offset < 0) if (-Offset < OutsideShortestDistance) OutsideShortestDistance = -Offset; pNextRequestw = pRequest;if(ScanInside)if(pNextRequestn!=NULL) pNextRequest=pNextRequestn;elsepNe
17、xtRequest=pNextRequestw; ScanInside=!ScanInside;elseif(pNextRequestw!=NULL) pNextRequest=pNextRequestw;elsepNextRequest=pNextRequestn; ScanInside=!ScanInside;RETURN:return pNextRequest;运行结果:* Disk schedule start working *Start Cylinder: 10TID: 37 Cylinder: 10 Offset: 0 =TID: 40 Cylinder: 10 Offset: 0 =TID: 39 Cylinder: 12 Offset: 2 +TID: 32 Cylinder: 21 Offset: 9 +TID: 36 Cylind
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
评论
0/150
提交评论