-
2019-09-03 22:55:31
移臂调度算法又叫磁盘调度算法,根本目的在于有效利用磁盘,保证磁盘的快速访问。
分为四类,1.先来先服务算法:只考虑访问者提出访问请求的先后顺序。
2.最短寻找时间优先调度算法:从等待的访问者中挑选寻找时间最短的那个请求执行。
3.电梯调度算法:从移动臂当前位置沿移动方向选择最近的那个柱面的访问者来执行。
4单项扫描调度算法:总是从0号柱面开始向里道扫描,按照柱面位置顺序去选择访问者,直到移动臂到达最后一个柱面后,立即返回到0号柱面,再次进行扫描。更多相关内容 -
磁盘移臂调度算法实验
2021-05-26 00:34:13操作系统实验报告实验题目:实验八:磁盘移臂调度算法实验软件环境:Linux操作系统实验目的:加深对于操作系统设备管理技术的了解,体验磁盘移臂调度算法的重要性;掌握几种重要的磁盘移臂调度算法,练习模拟算法的...操作系统实验报告
实验题目:实验八:磁盘移臂调度算法实验
软件环境:Linux操作系统
实验目的:加深对于操作系统设备管理技术的了解,体验磁盘移臂调度算法的重要性;掌握几种重要的磁盘移臂调度算法,练习模拟算法的编程技巧,锻炼研究分析试验数据的能力。
实验内容:请在示例实验程序中补充SCAN,C-SCAN,LOOK磁盘移臂调度算法的模拟程序。输入不同的磁盘柱面请求序列,观察和分析其调度效果和性能,并将其与FCFS和SSTF算法进行比较。改进以上示例实验程序,使之能够随机的产生磁盘柱面请求序列,以便能动态的观测各种调度算法的性能。
实验思路:首先明确了SCAN,C-SCAN,LOOK磁盘移臂调度算法的思想,明确需要完成的任务即给出寻道序列,并根据方向转换次数和寻到数分析算法的优劣并比较。其次,结合私立程序给出的SSTF算法和SCAN算法,写出SCAN,C-SCAN,LOOK算法,并添加到示例程序中。编译后执行,多次磁盘请求序列的测试,查看实验结果是否正确。
实验代码://dask.h
#include
#include
#include
#include
#include
using namespace std;
class DiskArm{
public:
DiskArm();
~DiskArm();
void InitSpace(char * MethodName); //初始化寻道记录
void Report(void); // 报告算法执行情况
void Fcfs(void); //先来先服务算法
void Sstf(void); //最短寻道时间优先算法
void Scan(void); //电梯调度算法
void CScan(void); //均匀电梯调度算法
void Look(void); //LOOK 调度算法
private:
int *Request ;
//磁盘请求道号
int *Cylinder;
//工作柱面道号号
int RequestNumber;
//磁盘请求数
int CurrentCylinder;
//当前道号
int SeekDirection;
//磁头方向
int SeekNumber;
//移臂总数
int SeekChang;
//磁头调头数
};
//dask.c
#include "dask.h"
DiskArm::DiskArm(){
int
i;
//输入当前道号
cout
<< "Please input Current cylinder :"
;
cin
>> CurrentCylinder;
//磁头方向,输入 0 表示向小道号移动,1 表示向大道号移动
cout
<< "Please input Current Direction
(0/1) :" ;
cin
>> SeekDirection;
//输入磁盘请求数,请求道号
cout
<< "Please input Request Numbers :"
;
cin
>> RequestNumber;
cout
<< "Please input Request cylinder
string :";
Request =
new int[sizeof(int) * RequestNumber];
Cylinder
= new int[sizeof(int) * RequestNumber];
for (i =
0; i < RequestNumber; i++)
cin
>> Request[i];
}
DiskArm::~DiskArm(){
}
//初始化道号,寻道记录
void DiskArm::InitSpace(char * MethodName)
{
int
i;
cout
<< endl
<< MethodName
<< endl;
SeekNumber = 0;
SeekChang
= 0;
for (i =
0; i < RequestNumber; i++)
Cylinder[i] = Request[i];
}
// 统计报告算法执行情况
void DiskArm::Report(void){
cout
<< endl;
cout
<< "Seek Number: "
<< SeekNumber
<< endl;
cout
<< "Chang Direction: "
<< SeekChang
<< endl
<< endl;
}
//先来先服务算法
void DiskArm::Fcfs(void)
{
int
Current = CurrentCylinder;
int
Direction = SeekDirection;
InitSpace("FCFS");
cout
<< Current;
for(int
i=0; i
if(((Cylinder[i] >= Current)
&& !Direction)||((Cylinder[i]
< Current) &&
Direction)){
//需要调头
SeekChang++; //调头数加 1
Direction = !Direction ; //改变方向标志
//报告当前响应的道号
cout << endl
<< Current
<< " -> "
<< Cylinder[i];
}
else //不需调头,报告当前响应的道号
cout << " -> "
<< Cylinder[i] ;
//累计寻道数,响应过的道号变为当前道号
SeekNumber += abs(Current -Cylinder[i]);
Current = Cylinder[i];
}
//报告磁盘移臂调度的情况
Report();
}
void DiskArm::Sstf(void)
{
int
Shortest;
int
Distance = 999999 ;
int
Direction = SeekDirection;
int
Current = CurrentCylinder;
InitSpace("SSTF");
cout
<< Current;
for(int
i=0; i
//查找当前最近道号
for(int j=0; j
if(Cylinder[j] == -1) continue; //-1 表示已经响应过了
if(Distance > abs(Current-Cylinder[j])){
//到下一道号比当前距离近,下一道号为当前距离
Distance = abs(Current-Cylinder[j]);
Shortest = j;
}
}
if((( Cylinder[Shortest] >= Current)
&& !Direction)||((
Cylinder[Shortest] < CurrentCylinder)
&& Direction)){
//需要调头
SeekChang++; //调头数加 1
Direction = !Direction ; //改变方向标志
//报告当前响应的道号
cout << endl
<< Current
<< " -> "
<< Cylinder[Shortest];
}
else //不需调头,报告当前响应的道号
cout << " -> "
<< Cylinder[Shortest] ;
//累计寻道数,响应过的道号变为当前道号
SeekNumber += abs(Current -Cylinder[Shortest]);
Current = Cylinder[Shortest];
//恢复最近距离,销去响应过的道号
Distance = 999999;
Cylinder[Shortest] = -1;
}
Report();
}
//电梯调度算法
void DiskArm::Scan(void){
int
Current = CurrentCylinder;
int
Direction = SeekDirection;
InitSpace("SCAN");
cout
<< Current;
for(int
i=0; i
int index=-1;
int Distance = 999999;
for(int j=0;j
if(Cylinder[j]==-1)
continue;
else
if((Direction==0&&Cylinder[j]
||(Direction==1&&Cylinder[j]>Current&&(Cylinder[j]-Current)
index=j;
Distance=abs(Current-Cylinder[j]);
}
}
if(Direction==0){
if(index!=-1){
cout<"<
SeekNumber+=Current-Cylinder[index];
Current=Cylinder[index];
Cylinder[index]=-1;
}else{
cout<"<<0<
SeekNumber+=Current;
Direction=!Direction;
//cout<<0;
Current=0;
SeekChang++;
i--;
}
}
else if(Direction==1){
if(index!=-1){
cout<"<
SeekNumber+=Cylinder[index]-Current;
Current=Cylinder[index];
Cylinder[index]=-1;
}else{
cout<"<<199<
SeekNumber+=199-Current;
Direction=!Direction;
//cout<<199;
Current=199;
SeekChang++;
i--;
}
}
}
//报告磁盘移臂调度的情况
Report();
}
//均匀电梯调度算法
void DiskArm::Look(void){
int
Current = CurrentCylinder;
int
Direction = SeekDirection;
InitSpace("Look");
cout
<< Current;
for(int
i=0; i
int index=-1;
int Distance = 999999;
for(int j=0;j
if(Cylinder[j]==-1)
continue;
else
if((Direction==0&&Cylinder[j]
||(Direction==1&&Cylinder[j]>Current&&(Cylinder[j]-Current)
index=j;
Distance=abs(Current-Cylinder[j]);
}
}
if(Direction==0){
if(index!=-1){
cout<"<
SeekNumber+=Current-Cylinder[index];
Current=Cylinder[index];
Cylinder[index]=-1;
}else{
//cout<
Direction=!Direction;
SeekChang++;
i--;
}
}
else if(Direction==1){
if(index!=-1){
cout<"<
SeekNumber+=Cylinder[index]-Current;
Current=Cylinder[index];
Cylinder[index]=-1;
}else{
//cout<
Direction=!Direction;
SeekChang++;
i--;
}
}
}
//报告磁盘移臂调度的情况
Report();
}
//LOOK 调度算法
void DiskArm::CScan(void)
{
int Current = CurrentCylinder;
int
Direction = SeekDirection;
InitSpace("CScan");
cout
<< Current;
for(int
i=0; i
int index=-1;
int Distance = 999999;
for(int j=0;j
if(Cylinder[j]==-1)
continue;
else
if((Direction==0&&Cylinder[j]
||(Direction==1&&Cylinder[j]>Current&&(Cylinder[j]-Current)
index=j;
Distance=abs(Current-Cylinder[j]);
}
}
if(Direction==0){
if(index!=-1){
cout<"<
SeekNumber+=Current-Cylinder[index];
Current=Cylinder[index];
Cylinder[index]=-1;
}else{
cout<"<<0<
SeekNumber+=Current;
Current=199;
cout<199";
SeekChang++;
i--;
}
}
else if(Direction==1){
if(index!=-1){
cout<"<
SeekNumber+=Cylinder[index]-Current;
Current=Cylinder[index];
Cylinder[index]=-1;
}else{
cout<"<<199<
SeekNumber+=199-Current;
Current=0;
SeekChang++;
i--;
}
}
}
Report();
}
//程序启动入口
int main(int argc,char *argv[]){
//建立磁盘移臂调度类
DiskArm *dask = new DiskArm();
//比较和分析 FCFS 和 SSTF 两种调度算法的性能
dask->Fcfs();
dask->Sstf();
dask->Scan();
dask->CScan();
dask->Look();
}
-
操作系统模拟移臂调度算法c语言代码
2014-04-15 08:45:58操作系统模拟移臂调度算法c语言代码,操作系统课程设计(移臂调度) -
java的磁盘移臂调度算法
2018-12-24 20:46:16简单的磁盘移臂调度算法,FCFS,SSTF,Scan和电梯算法 有简单的界面显示 用的java语言 -
操作系统实验八 磁盘移臂调度算法实验
2011-05-14 11:57:16操作系统实验八:磁盘移臂调度算法实验报告。实验目标:加深对于操作系统设备管理技术的了解,体验磁盘移臂调度算法的重要性;掌握几种重要的磁盘移臂调度算法,练习模拟算法的编程技巧,锻炼研究分析试验数据的能力... -
山东大学操作系统实验八 磁盘移臂调度算法实验
2014-05-29 22:48:24山东大学操作系统实验八 磁盘移臂调度算法实验 -
磁盘调度管理实验——移臂调度算法代码(Java)
2022-05-15 11:54:512.最短寻找时间优先调度算法 3.单向扫描调度算法 4.双向扫描调度算法 5.电梯调度算法 代码如下: //测试例子 98 183 37 122 14 124 65 67 -1 //测试例子 98 183 37 122 14 124 65 67 -1 //测试例子 98 183 37 122...本代码包含了
1.先来先服务算法
2.最短寻找时间优先调度算法
3.单向扫描调度算法
4.双向扫描调度算法
5.电梯调度算法代码如下:
//测试例子 98 183 37 122 14 124 65 67 -1 //测试例子 98 183 37 122 14 124 65 67 -1 //测试例子 98 183 37 122 14 124 65 67 -1 //测试例子 98 183 37 122 14 124 65 67 -1 import java.util.*; public class ArmShiftSchedulingAlgorithm { private int arm;//模拟移动臂 private int distance = 0;//保存移动臂移动距离 private int surfaceNum = 0;//保存柱面数 //生成队列保存输入序列 LinkedList<Integer> intputQueue(){ Scanner in = new Scanner(System.in); LinkedList<Integer> inputQueue = new LinkedList<Integer>(); int temp = -1; temp = in.nextInt(); while(temp != -1) { inputQueue.offer(temp); temp = in.nextInt(); } return inputQueue; } //模拟移动臂移动 void move(int address) { for(int i = 0;i < Math.abs(address - arm);i++) { try { Thread.sleep(10); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } System.out.print("到达柱面" + address + " >> "); distance += Math.abs(address - arm); arm = address; } //输出访问序列 void showOutputQueue(LinkedList<Integer> outputQueue) { System.out.print("柱面响应序列为:"); while(!outputQueue.isEmpty()) { System.out.print(outputQueue.poll() + " "); } System.out.println(); System.out.println("总移动柱面个数:" + distance + "\n"); System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); } //生成选择菜单 @SuppressWarnings("resource") void menu() { System.out.print("请你输入请求访问的柱面序列(以-1作为结束标志):"); LinkedList<Integer> intputQueue = intputQueue(); System.out.print("请输入移动臂的初始位置:"); arm = (new Scanner(System.in)).nextInt(); System.out.print("请输入最里的柱面号:"); surfaceNum = (new Scanner(System.in)).nextInt(); System.out.println("\n请你选择算法"); System.out.println("1.先来先服务算法"); System.out.println("2.最短寻找时间优先调度算法"); System.out.println("3.单向扫描调度算法"); System.out.println("4.双向扫描调度算法"); System.out.println("5.电梯调度算法"); System.out.println("0.退出"); System.out.println(""); System.out.print("请选择:"); int selectFunction = (new Scanner(System.in)).nextInt(); while(selectFunction != 0) { switch(selectFunction) { case 1: System.out.println("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); System.out.println("\n\t\t先来先服务算法\n"); execFiFOArithmetic(intputQueue); break; case 2: System.out.println("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); System.out.println("\n\t\t最短寻找时间优先调度算法\n"); execSSTFArithmetic(intputQueue); break; case 3: System.out.println("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); System.out.println("\n\t\t单向扫描调度算法\n"); execOneWayScanArithmetic(intputQueue); break; case 4: System.out.println("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); System.out.println("\n\t\t双向扫描调度算法\n"); execDoubleWayScanArithmetic(intputQueue); break; case 5: System.out.println("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); System.out.println("\n\t\t电梯调度算法\n"); execElevatorSchedulingArithmetic(intputQueue); break; default: System.out.println("\n你的输入不正确!"); break; } System.out.print("请你输入请求访问的柱面序列(以-1作为结束标志):"); intputQueue = intputQueue(); System.out.print("请输入移动臂的初始位置:"); arm = (new Scanner(System.in)).nextInt(); System.out.print("请输入最里的柱面号:"); surfaceNum = (new Scanner(System.in)).nextInt(); System.out.println("\n请你选择算法"); System.out.println("1.先来先服务算法"); System.out.println("2.最短寻找时间优先调度算法"); System.out.println("3.单向扫描调度算法"); System.out.println("4.双向扫描调度算法"); System.out.println("5.电梯调度算法"); System.out.println("0.退出"); System.out.println(""); System.out.print("请选择:"); selectFunction = (new Scanner(System.in)).nextInt(); distance = 0; } } //FIFO算法 LinkedList<Integer> FIFOArithmetic(LinkedList<Integer> queue1){ LinkedList<Integer> outputQueue = new LinkedList<Integer>(); while(!queue1.isEmpty()) { int popNum = queue1.poll(); outputQueue.offer(popNum); move(popNum); } System.out.println(""); return outputQueue; } void execFiFOArithmetic(LinkedList<Integer> InputQueue) { showOutputQueue( FIFOArithmetic(InputQueue)); } //SSTF算法 //1.先创建一个临时队列 //2.再把队列的值和当前arm的值相减 //3.从队列中找出最小的值 //4.将该值加上当前arm的值后进入一个新的队列 //5,将新进入的值从旧的队列中删除 //6.重复1直到队列为空 LinkedList<Integer> SSTFArithmetic(LinkedList<Integer> queue1){ LinkedList<Integer> outputQueue = new LinkedList<Integer>(); while(!queue1.isEmpty()) { findMin2AddOutputQueue(queue1,outputQueue); } return outputQueue; } //把队列中的最小值添加到输出对列 void findMin2AddOutputQueue(LinkedList<Integer> InputQueue,LinkedList<Integer> outputQueue) { int min = -999999; int temp = 0; LinkedList<Integer> tempQueue = new LinkedList<Integer>(InputQueue); Iterator<Integer> it = tempQueue.iterator(); int i = 1; int minNum = 1; if(it.hasNext()) min = it.next()- arm; while(it.hasNext()) { temp = it.next() - arm; i++; if(Math.abs(temp) < Math.abs(min)) { min = temp; minNum = i; } } outputQueue.offer(min + arm); InputQueue.remove(minNum - 1); move(min + arm); } void execSSTFArithmetic(LinkedList<Integer> InputQueue) { LinkedList<Integer> outputQueue = SSTFArithmetic(InputQueue); System.out.println(""); showOutputQueue(outputQueue); } //单向扫描算法 //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> void OneWayScanArithmetic(LinkedList<Integer> queue1,LinkedList<Integer> outputQueueL,LinkedList<Integer> outputQueueR){ int[] array = changeQueueToOrderIntArray(queue1); boolean firstAdd = true; int firstAddr = 0; for(int i = 0;i < array.length;i++) { if(array[i] >= arm) { if(firstAdd == true) { firstAdd = false; firstAddr = i; } outputQueueL.offer(array[i]); move(array[i]); } } move(surfaceNum); move(0); for(int i = 0;i < firstAddr;i++) { outputQueueL.offer(array[i]); move(array[i]); } System.out.println(); showOutputQueue(outputQueueL); } //把输入队列转换成有序数组 int[] changeQueueToOrderIntArray(LinkedList<Integer> InputQueue) { int[] array = new int[InputQueue.size()]; Iterator<Integer> it = InputQueue.iterator(); for(int i = 0;i < array.length;i++) { array[i] = it.next(); } return insertArithmetic(array); } //插入排序算法 int[] insertArithmetic(int[] array) { int len = array.length; int temp; for(int i = 1;i < len;i++) { temp = array[i]; int j; for(j = i - 1;j >= 0;j--) { if(temp < array[j]) { array[j+1] = array[j]; } else break; } array[j + 1] = temp; } return array; } void execOneWayScanArithmetic(LinkedList<Integer> InputQueue) { distance = 0; LinkedList<Integer> OutputLeftQueue = new LinkedList<Integer>(); LinkedList<Integer> OutputRightQueue = new LinkedList<Integer>(); OneWayScanArithmetic(InputQueue,OutputLeftQueue,OutputRightQueue); } //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> //双向扫描算法 void DoubleWayScanArithmetic(LinkedList<Integer> queue1,LinkedList<Integer> outputQueueL,LinkedList<Integer> outputQueueR){ int[] array = changeQueueToOrderIntArray(queue1); boolean firstAdd = true; int firstAddr = 0; for(int i = 0;i < array.length;i++) { if(array[i] >= arm) { if(firstAdd == true) { firstAdd = false; firstAddr = i; } outputQueueL.offer(array[i]); move(array[i]); } } move(surfaceNum); for(int i = firstAddr - 1;i >= 0;i--) { outputQueueL.offer(array[i]); move(array[i]); } System.out.println(); showOutputQueue(outputQueueL); } void execDoubleWayScanArithmetic(LinkedList<Integer> InputQueue) { distance = 0; LinkedList<Integer> OutputLeftQueue = new LinkedList<Integer>(); LinkedList<Integer> OutputRightQueue = new LinkedList<Integer>(); DoubleWayScanArithmetic(InputQueue,OutputLeftQueue,OutputRightQueue); } //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> //电梯调度算法 void ElevatorSchedulingArithmetic(LinkedList<Integer> queue1,LinkedList<Integer> outputQueueL,LinkedList<Integer> outputQueueR){ int tempArm1 = arm; //从右向左扫描 System.out.println("移动臂由外向里移动:"); int[] array = changeQueueToOrderIntArray(queue1); boolean firstAdd = true; int firstAddr = 0; for(int i = 0;i < array.length;i++) { if(array[i] >= arm) { if(firstAdd == true) { firstAdd = false; firstAddr = i; } outputQueueL.offer(array[i]); move(array[i]); } } for(int i = firstAddr - 1;i >= 0;i--) { outputQueueL.offer(array[i]); move(array[i]); } System.out.println(""); showOutputQueue(outputQueueL); System.out.println(""); //从左向右扫描 System.out.println("移动臂由里向外移动:"); distance = 0; arm = tempArm1; firstAdd = true; firstAddr = 0; for(int i = array.length - 1;i >= 0;i--) { if(array[i] <= arm) { if(firstAdd == true) { firstAdd = false; firstAddr = i; } outputQueueR.offer(array[i]); move(array[i]); } } for(int i = firstAddr + 1;i < array.length;i++) { outputQueueR.offer(array[i]); move(array[i]); } System.out.println(""); showOutputQueue(outputQueueR); } void execElevatorSchedulingArithmetic(LinkedList<Integer> InputQueue) { distance = 0; LinkedList<Integer> OutputLeftQueue = new LinkedList<Integer>(); LinkedList<Integer> OutputRightQueue = new LinkedList<Integer>(); ElevatorSchedulingArithmetic(InputQueue,OutputLeftQueue,OutputRightQueue); } }
测试类Java文件:
public class runTest { public static void main(String args[]) { (new ArmShiftSchedulingAlgorithm()).menu(); } }
运行结果如下:
-
操作系统之移臂调度算法
2021-02-03 22:51:33速成操作系统移臂调度算法,包括先来先服务算法(FCFS)、最短查找时间优先算法、扫描算法、电梯调度算法和循环扫描算法。本章分享操作系统之移臂调度算法,移臂调度算法是驱动调度技术中的算法,目的是减少为若干I/O请求服务所需消耗的总时间,从而提高系统效率。常见的移臂调度算法有先来先服务算法(FCFS)、最短查找时间优先算法、扫描算法、电梯调度算法和循环扫描算法。本章将逐步讲解各个算法的实现方法。
本章同样适用于普通本科院校的学生期末复习和计算机学院老师板书参考。
我们用一道例题来具体讲解下面的各种算法。
假设磁盘机共有200个柱面,编号0至199,考虑依次到达下列柱面访问请求序列:150,30,190,20,100,55,90
同时假如磁头当前处于50号柱面位置,且正在向柱面号大的方向移动。至此,我们可以得出一张图:
先来先服务算法
先来先服务算法中,磁盘臂是随机移动的,不考虑各I/O请求之间的相对次序和移动臂当前所处位置,特点是进程等待I/O请求的时间会很长,寻道性能较差。
简单来说,就按题目中所给的柱面依次进行到达,题目中是150,30,190,20,100,55,90,那就先去150,再绕回去30,再绕去190…等待。如图所示:
故移动臂移动柱面总数=(150-50)+(150-30)+(190-30)+(190-20)+(100-20)+(100-55)+(90-55)=710注意:移动柱面总数就是把经过都加起来,例如第一步是50到150,经历的柱面书就是100
最短查找时间优先算法
最短查找时间优先算法总是先执行查找时间最短的请求,与FCFS算法相比有较好的寻道性能。简单来说,就是先去距离近的,例如本题中,离50最近的是55,就先去55,离55最近的是30,就先去30,以此类推,如图所示:
故移动臂移动柱面总数=(55-50)+(55-30)+(30-20)+(90-20)+(100-90)+(150-100)+(190-150)=210相比较FCFS,是不是少了很多柱面!?
扫描算法
扫面柱面就是“撞到南墙才回头”,往一个方向扫柱面后,就一直往那个方向扫,直到那个方向的柱面都扫完了才往反方向扫,例如本题,50往55方向扫,55的下一步就是90,90的下一步就是100…直到190的下一步199,再往回扫。
注意,按照扫描算法规则,即使没有访问请求也须扫描到头,所以到达要求的190后还要扫到199。如图所示:
故移动臂移动柱面总数=(55-50)+(90-55)+(100-90)+(150-100)+(190-150)+(199-190)+(199-30)+(30-20)=328电梯调度算法
电梯调度算法是扫描算法的一种改进,每次总是选择沿移动臂的移动方向最近的那个柱面,若同一个柱面上有多个请求,还需进行旋转优化。如果当前的移动方向上没有但相反方向有访问请求时,就改变移动臂的移动方向。
本例题中,电梯调度算法的图示情况如下:
相对于扫描算法来说,并没有扫到199,因为到达190后没有要求的柱面,所以就往相反方向扫描,就跟电梯一样,从1楼乘往18楼,如果中间楼层的人想搭电梯下楼,是要先等电梯到达18楼后再往下走。移动臂移动柱面总数=(55-50)+(90-55)+(100-90)+(150-100)+(190-150)+(190-30)+(30-20)=310
循环扫描算法
循环扫描算法就更简单了,往一个方向扫描后,扫完了,直接重新从反方向的开始方向扫剩下的,不多说,直接上图!:
移动臂移动柱面总数=(55-50)+(90-55)+(100-90)+(150-100)+(190-150)+(150-100)+(190-150)+(199-190)+(199-0)+(20-0)+(30-20)=378本例题来自书
操作系统教程(第5版)费翔林 骆斌 编著
p270-274其余操作系统的算法可在博主空间找到!
感谢大家浏览,谢谢!
-
实验八、磁盘移臂调度算法实验
2010-05-25 12:13:02请在以上示例实验程序中补充 SCAN,C-SCAN,LOOK 磁盘移臂调度算法的模 拟程序。输入不同的磁盘柱面请求序列,观察和分析其调度效果和性能,并将其与 FCFS 和 SSTF 算法进行比较。改进以上示例实验程序,使之能够随机的... -
操作系统:磁盘的移臂调度算法
2020-12-13 21:49:42对于常见磁盘的移臂调度算法进行了介绍!(先来先服务调度算法FCFS、最短查找时间优先算法SSTF、电梯调度算法SCAN、N步扫描策略、循环扫描策略、FSCAN算法) -
最短移臂调度算法_SCAN(扫描调度算法),又名电梯算法,是计算机磁盘驱动调度的方法...
2020-11-20 17:00:34之前笔者和大家讨论过FCFS(先来先服务算法)和SSTF(最短路径搜索算法),那么今天我们就来讨论在计算机磁盘驱动调度当中,一种比较重要的算法,叫做SCAN(扫描调度算法),又叫做电梯算法谈到电梯,大家往往会想到现实中... -
最短移臂调度算法_论文 | 一种有趣的装配序列规划算法
2020-10-26 00:31:56一种有趣的装配序列规划算法作者:张楠 (浙江大学 在读博士) 精要导读问题背景在正式介绍装配序... -
移臂调度算法模拟 C/C++版
2019-05-21 20:23:04手动操作,可以自己实现任何一种移臂调度算法(先来先服务算法、最短寻找时间优先调度算法、单向扫描调度算法、电梯调度算法) #include<iostream> #include<cstdlib> #include<cstdio> #... -
先来先服务移臂调度算法.doc
2022-05-07 17:02:08先来先服务移臂调度算法.doc -
操作系统实验 Java模拟处理器调度 存储管理 磁盘移臂调度 文件管理 算法
2019-06-22 11:24:22处理器调度算法: 先来先服务, 时间片轮转, 短作业优先, 最高响应比优先 存储管理: FIFO, LRU 磁盘移臂调度: SSTF, SCAN 文件管理: 运用空闲盘块表的方式组织磁盘空间, 模拟文件的 create() 和 delete() 操作 -
移臂调度算法演示 操作系统 计算机 编程
2011-02-16 22:58:44移臂调度算法演示,是操作系统的课程设计,用JAVA编写。包含先来先服务算法,最短寻道时间算法,电梯调度,扫描算法,其中电梯调度和扫描算法都可以选择方向。先输入参数:作业数,当前位置,然后动态生成队列,包含... -
移臂调度算法研究.pdf
2021-09-21 19:29:04移臂调度算法研究.pdf -
移臂调度算法(操作系统作业)
2008-12-13 22:27:27本算法是操作系统的实验课要求之一...主要是模拟磁盘移臂调度算法.... -
基于Java的移动臂磁盘调度算法(动态显示)
2019-01-07 09:12:40使用Java实现操作系统中移动臂磁盘调度算法,包括先来先服务调度算法、最短寻找时间优先调度算法、电梯调度算法、单向扫描和双向扫描调度算法,有简单的图形用户界面和通过线程动态显示 -
操作系统 磁盘移臂调度算法
2016-06-02 15:35:441. 示例实验程序中模拟两种磁盘移臂调度算法:SSTF算法和SCAN算法 2. 能对两种算法给定任意序列不同的磁盘请求序列,显示响应磁盘请求的过程。 3. 能统计和报告不同算法情况下响应请求的顺序、移臂的总量。 ps:... -
java语言移动臂算法调度模拟报告
2019-02-02 15:57:27适用于南京工程学院操作系统课程实验,磁盘移臂调度模拟算法 -
最短移臂调度算法_智能优化算法-蚁群算法
2020-11-19 17:11:52蚁群算法主要用于求解旅行商(TSP)问题、分配调度问题、车间调度作业(job-shop)问题,并取得较好的试验结果。一, 蚁群算法概述自然界中有一个神奇的现象,即蚂蚁在没有提示的情况下总是能够找到从巢穴到食物的... -
操作系统实验报告八(磁盘移臂调度算法实验)
2014-08-06 14:31:26本实验为“磁盘移臂调度算法实验”,操作系统经典实验,实验目的为:加深对于操作系统设备管理技术的了解,体验磁盘移臂调度算法的重要性;掌握几种重要的磁盘移臂调度算法,练习模拟算法的编程技巧,锻炼研究分析试验... -
最短移臂调度算法_MATLAB优化算法实例——蚁群算法
2020-10-21 18:59:12❝欢迎关注「工科男的Maltab学习日志」,采用...——工科男❞1 蚁群算法基本理论介绍遗传算法(Genetic Algorithm 简称GA)与模拟退火算法(Simulated Annealing Algorithm)后,本章介绍蚁群算法(ant colony algorit... -
自考操作系统之移臂调度及其算法
2021-01-11 14:18:02I/O设备 如上图,柱面号的开始点:50(开始点可为任一点,根据当前移动臂停留柱面号确定,为0,为159都可以,具体计算看题目给出的),根据先来先服务的原则,...最短寻找时间优先调度算法会很容易出现饥饿现象 -
操作系统磁盘调度算法实验
2020-10-12 22:13:05假设有 n 个磁道号所组成 的磁道访问序列,给定开始磁道号 m 和磁头移动的方向,正向 或者反向,分别利用不同的磁盘调度算法访问磁道序列,给出 每一次访问的磁头移动距离,计算每种算法的平均寻道长度 -
磁盘移臂调度算法 简介
2012-06-22 18:20:23移臂调度算法又叫磁盘调度算法,根本目的在于有效利用磁盘,保证磁盘的快速访问。 1) 先来先服务算法:该算法实际上不考虑访问者要求访问的物理位置,而只是考虑访问者提出访问请求的先后次序。有可能随时... -
磁盘调度算法:在python中模拟磁盘调度算法,例如FCFS,SSTF,SCAN,C-SCAN,LOOK,C-LOOK
2021-02-04 10:27:17如何使用代码: ... 磁盘调度算法 磁盘调度是由操作系统完成的,以调度到达磁盘的I / O请求。 磁盘调度也称为I / O调度。 磁盘调度很重要,因为: Multiple I/O requests may arrive by different processe -
操作系统中磁盘调度算法(FIFO,SSTF,SCAN,C-SCAN)
2021-01-20 14:52:29FIFO:先进先出的调度策略,这个策略具有公平的优点,因为每个请求都会得到处理,并且是按照接收到的顺序进行处理 ... 磁盘调度算法的数据比较 磁盘调度算法的描述 磁盘调度算法的直观比较 -
[软考的题目] 移臂调度算法又叫磁盘调度算法
2012-09-19 14:26:04原帖:http://baike.baidu.com/view/1661359.htm移臂调度算法又叫磁盘调度算法,根本目的在于有效利用磁盘,保证磁盘的快速访问。 1) 先来先服务算法:该算法实际上不考虑访问者要求访问的物理位置,而只是考虑...