




已阅读5页,还剩6页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
操作系统实 验 报 告课程名称操作系统实验实验项目名称磁盘调度算法学号2010061304班级20100613姓名王鸿运专业计算机学生所在学院计算机科学与技术指导教师王红滨实验室名称地点计算机基础第七实验室 哈尔滨工程大学计算机科学与技术学院一、实验概述1. 实验名称 磁盘调度算法2. 实验目的 (1)通过学习EOS实现磁盘调度算法的机制,掌握磁盘调度算法执行的条件和时机。 (2)观察EOS实现的FCFS、SSTF和 SCAN磁盘调度算法,了解常用的磁盘调度算法。 (3)编写CSCAN和N-Step-SCAN磁盘调度算法,加深对各种扫描算法的理解。3. 实验类型 验证,设计4. 实验内容(1)准备实验(2) 验证先来先服务(FCFS)磁盘调度算法(3) 验证最短寻道时间优先(SSTF)磁盘调度算法(4) 验证SSTF算法造成的线程“饥饿”现象(5.1) 验证扫描(SCAN)磁盘调度算法(5.2) 验证SCAN 算法能够解决“饥饿”现象(6) 改写SCAN调度算法二、实验环境EOS操作系统与IDE环境组成的“操作系统集成实验环境OS Lab”。三、实验过程(一)实验问题及解答1.实验指导P176-3.2验证先来先服务(FCFS)磁盘调度算法,要求请给出在“输出”窗口中的结果。 答:输出结果复制如下:制作软盘镜像.正在启动 Virtual PC.开始调试.* 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 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验证验证最短寻道时间优先(SSTF)磁盘调度算法,要求请给出在“输出”窗口中的结果。 答:输出结果复制如下:制作软盘镜像.正在启动 Virtual PC.开始调试.* 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 Cylinder: 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算法造成的线程“饥饿”现象,要求请给出在“输出”窗口中的结果。 答:输出结果复制如下:制作软盘镜像.正在启动 Virtual PC.开始调试.* 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: 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: 72 Transfer times: 10 Average offset: 74. 实验指导P179-3.5验证扫描(SCAN)磁盘调度算法,要求在非饥饿(即实验指导P176-3.2节中的数据)和饥饿(即实验指导P178-3.4节中的数据)请给出在“输出”窗口中的结果,并且要求在每次输入两次“ds”命令(注意不要连续输入,要等第一次“ds”命令执行完,再输入第二次“ds”命令),分析结果为什么不同。答:输出结果复制如下:(1)非饥饿状态,两次输入ds指令制作软盘镜像.正在启动 Virtual PC.开始调试.* 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 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 offset: 146 Transfer times: 10 Average offset: 14* Disk schedule stop working * 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: 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(2) 饥饿状态,两次输入ds指令制作软盘镜像.正在启动 Virtual PC.开始调试.* Disk schedule start working *Start Cylinder: 10TID: 37 Cylinder: 10 Offset: 0 =TID: 40 Cylinder: 10 Offset: 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: 10 Average offset: 13* Disk schedule stop working * 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 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命令后,该次搜索的指针方向被保存,但是和初始值相比,搜索的方向发生了变化。根据SCAN算法,按一个方向访问磁盘,一个方向访问到尽头后再换一个方向继续访问。下次访问,按上次访问结束时的方向继续访问。于是第二次访问的方向会与第一次不同,造成两次DS命令输出的结果不同。(2) 实验代码及解释实验结果:制作软盘镜像.正在启动 Virtual PC.开始调试.* 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 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 offset: 146 Transfer times: 10 Average offset: 14* Disk schedule stop working * 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: 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源代码:PREQUESTIopDiskSchedule(VOID)PLIST_ENTRY pListEntry;PREQUEST pRequest;LONG Offset;ULONG InsideShortestDistance = 0xFFFFFFFF;ULONG OutsideShortestDistance = 0xFFFFFFFF;PREQUEST pNextRequest0 = NULL,pNextRequest1=NULL,pNextRequest2=NULL;/ 需要遍历请求队列一次或两次/for (pListEntry = RequestListHead.Next;/ 请求队列中的第一个请求是链表头指向的下一个请求。 pListEntry != &RequestListHead;/ 遍历到请求队列头时结束循环。 pListEntry = pListEntry-Next) / 根据链表项获得请求的指针/pRequest = CONTAINING_RECORD(pListEntry, REQUEST, ListEntry);/ 计算请求对应的线程所访问的磁道与当前磁头所在磁道的偏移(方向由正负表示)/Offset = pRequest-Cylinder - CurrentCylinder;if (0 = Offset) / 如果线程要访问的磁道与当前磁头所在磁道相同,可立即返回。/pNextRequest0 = pRequest;return pNextRequest0; if (Offset 0) / 记录向内移动距离最短的线程/if (Offset InsideShortestDistance) InsideShortestDistance = Offset;pNextRequest1 = pRequest; if ( Offset 0) / 记录向外移动距离最短的线程/
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 房产中介劳动合同范文
- 标准装饰工程合同书1
- 2025年文创产品数字化设计成果鉴定报告:设计创新大赛
- 金融科技企业估值与投资策略研究报告-2025年行业投资组合构建策略
- 工业互联网平台同态加密技术在我国2025年金融行业的应用前景报告
- 2025年壁挂炉环保节能产品采购及施工验收服务合同
- 2025年度员工股权激励计划与股权转让优化实施合同
- 2025年高端车床设备定制化维修及保养服务合同
- 2025年度节能减排技术应用与推广居间代理服务合同
- 2025年度离婚纠纷子女抚养权调解协议及执行合同
- 《儿童孟氏骨折》课件
- 《鸡防疫程序》课件
- 2024年河北港口集团有限公司招聘笔试参考题库含答案解析
- 《用户体验的要素》课件
- 基于现代文献探讨经方治疗冠心病(胸痹心痛)的处方用药规律研究演示稿件
- 钣金结构件点检表
- 一元二次不等式及解法
- 桩基工程验收监理质量评估报告
- 2022年脓毒血症指南解读(更新)
- 郭岩非煤矿山双重预防机制建设课件
- 中医揿针技术理论考核试题
评论
0/150
提交评论