




已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
操作系统实 验 报 告课程名称操作系统实验课程编号0920311实验项目名称磁盘调度算法学号年级姓名专业学生所在学院软件学院指导教师王宏斌实验室名称地点计算机软件第二实验室 21#282 第十讲 磁盘调度算法一、实验概述1. 实验名称磁盘调度算法2. 实验目的通过学习EOS实现磁盘调度算法的机制,掌握磁盘调度算法执行的条件和时机;观察EOS实现的FCFS、SSTF和SCAN磁盘调度算法,了解常用的磁盘调度算法;编写CSCAN和N-Step-SCAN磁盘调度算法,加深对各种扫描算法的理解。 3. 实验类型验证设计4. 实验内容理解EOS是如何实现磁盘调度算法的;学习EOS是如何测试磁盘调度算法的,并体会这种测试方法的优缺点。二、实验环境操作系统: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 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)磁盘调度算法,要求请给出在“输出”窗口中的结果。 * 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算法造成的线程“饥饿”现象,要求请给出在“输出”窗口中的结果。 * 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”命令),分析结果为什么不同。 非饥饿下第一次:* 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 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饥饿第一次:* 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 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的寻道方向不一样。由于定义了一个布尔类型的全局变量ScanInside,用于表示扫描算法中磁头移动的方向。该变量值为TRUE时表示磁头向内移动(磁道号增加);值为FALSE时表示磁头向外移动(磁道号减少)。该变量初始化为TRUE,表示SCAN算法第一次执行时,磁头向内移动。然后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 = 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 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; else pNextRequest=pNextRequestw; ScanInside=!ScanInside; else if(pNextRequestw!=NULL) pNextRequest=pNextRequestw; else pNextRequest=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 Cylinder: 4
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年洛阳汝阳县面向高等院校应届毕业生招聘教师41名模拟试卷及1套参考答案详解
- 安全培训被查课件
- 2025年琼中县教育局赴海师公开招聘教师和校医49名考前自测高频考点模拟试题及完整答案详解一套
- 2025海南保亭农水投资有限公司人员(代农水投公司发布)考前自测高频考点模拟试题及答案详解(典优)
- 2025华东理工大学材料科学与工程学院高分子材料人工智能研发创新团队招聘(上海)模拟试卷及答案详解参考
- 2025福建厦门市集美区海凤实验幼儿园非在编人员招聘1人考前自测高频考点模拟试题完整参考答案详解
- 2025年甘肃省武威市事业单位已发布模拟试卷及参考答案详解一套
- 2025包头市昆都仑区发展和改革委员会竞争性比选工作人员的考前自测高频考点模拟试题及答案详解(有一套)
- 2025年福建省厦门市湖里保安集团有限公司招聘1人考前自测高频考点模拟试题及答案详解(易错题)
- 2025年阜阳民生医院招聘20人考前自测高频考点模拟试题及答案详解(夺冠系列)
- 研究生教材SPSS统计软件应用
- 2025年部编版新教材三年级上册《9.犟龟》教案
- 2024年南宁市招聘中小学教师笔试真题
- 2024-2025学年下学期高二英语外研社版期中必刷常考题之被动语态
- 老员工带新员工的培训制度
- 水浒传每回内容梗概
- 工地试验室安全培训内容
- 合同车辆质押合同
- 2024版数据中心基础设施运维与维保服务合同2篇
- 增材制造课件
- 《《宫腔粘连多学科诊疗体系和效能评估标准》》
评论
0/150
提交评论