cymax | | cposn,java,c++,c,operating-system,Java,C++,C,Operating System" /> cymax | | cposn,java,c++,c,operating-system,Java,C++,C,Operating System" />

使用c,c+实现扫描盘调度+;还是java 学习系统的编程,如何实现C、C++或java的扫描磁盘调度算法。要求代码段实际访问磁盘句柄。下面是我一直在研究的代码示例,但问题是,它只是模拟扫描磁盘算法运行时实际发生的情况。标题位置和输入数据只是作为用户插入到程序中的值。我希望它能够真正读取当前的头位置,并排队请求,实现扫描磁盘调度或任何其他调度算法 #include<stdio.h> #include<conio.h> #include<math.h> #define max 15 #define cymax 249 int i,j,req,ttl_tracks=0,cp,np,cposn,nposn; int cyposn[max],temp; void input() { do { clreol(); printf("\n Enter the current header position : "); scanf("%d",&cposn); /*cposn current cylinder position which in this case is the same as the current header position*/ }while(cposn>cymax || cposn <=0); printf("\n Enter the %d I/O Requests : ",req); cyposn[0] = cposn; for(i=1;i<=req;i++) /*This for loop helps to store the different requests inputs in the array of cylinder positions cyposn: Note that the initial array cyposn stores the value of the initial header postion and that is why the for loop begins with 1 */ scanf("%d",&cyposn[i]); } void SCAN() /*function for the scanning schedule*/ { int tmp = cp; /*the tmp integer is used for swapping values, from the current cylinder position to the next*/ int ind = 0; for(i=0;i<=req;i++)/*this outer loops counts the number of requests*/ { for(j=0;j<req-i;j++) /*this inner loop walks through different values in the cylinder array which would later become sorted */ { if(cyposn[j] > cyposn[j+1])/*compares the two values previous position and the next position, if the previous is greater than the next position, the positions are swapped, taking the next position tobecome the current position a situation which would always ensure that the current position will become as small as possible: HENCE THE HANDLE WILL MOVE TO THE LEFT */ { temp = cyposn[j]; cyposn[j] = cyposn[j+1]; cyposn[j+1] = temp; } } } cp=0; /*when the loop finishes untill it finds the most minimal value: the handle is assigned to position '0' making the current position to be zero*/ do { if(cyposn[cp] == cposn) break; /*if it reaches the possible maximum cylinder value it breaks else it increments the values*/ cp++; }while(cp!=req); printf("\nS.No. Current Position Next Position Displacement \n"); printf("---------------------------------------------------------- \n\n"); i=0; cposn = cyposn[cp]; do { if(ind == 0) { if(cp == 0) { nposn = 0; ind = 1; } else nposn = cyposn[--cp]; } else { if(cp == 0) cp = tmp; nposn = cyposn[++cp]; } printf(" %d\t\t%d\t\t%d\t\t%d\n",++i,cposn,nposn,abs(cposn-nposn)); ttl_tracks += (abs(cposn-nposn)); cposn = nposn; }while(nposn!=cyposn[req]); printf("---------------------------------------------------------- \n\n"); printf(" Total Tracks Displaced : %d",ttl_tracks); } void main() { do { clrscr(); printf("\n Enter the number of requests : "); scanf("%d",&req); }while(req>max || req <=0); input(); SCAN(); getch(); } #包括 #包括 #包括 #定义最大值15 #定义cymax 249 int i,j,req,ttl_磁道=0,cp,np,cposn,nposn; 内部cyposn[max],温度; 无效输入() { 做 { clredol(); printf(“\n输入当前标题位置:”); scanf(“%d”和cposn); /*cposn当前气缸位置,在这种情况下是相同的 作为当前收割台位置*/ }而(cposn>cymax | | cposn

使用c,c+实现扫描盘调度+;还是java 学习系统的编程,如何实现C、C++或java的扫描磁盘调度算法。要求代码段实际访问磁盘句柄。下面是我一直在研究的代码示例,但问题是,它只是模拟扫描磁盘算法运行时实际发生的情况。标题位置和输入数据只是作为用户插入到程序中的值。我希望它能够真正读取当前的头位置,并排队请求,实现扫描磁盘调度或任何其他调度算法 #include<stdio.h> #include<conio.h> #include<math.h> #define max 15 #define cymax 249 int i,j,req,ttl_tracks=0,cp,np,cposn,nposn; int cyposn[max],temp; void input() { do { clreol(); printf("\n Enter the current header position : "); scanf("%d",&cposn); /*cposn current cylinder position which in this case is the same as the current header position*/ }while(cposn>cymax || cposn <=0); printf("\n Enter the %d I/O Requests : ",req); cyposn[0] = cposn; for(i=1;i<=req;i++) /*This for loop helps to store the different requests inputs in the array of cylinder positions cyposn: Note that the initial array cyposn stores the value of the initial header postion and that is why the for loop begins with 1 */ scanf("%d",&cyposn[i]); } void SCAN() /*function for the scanning schedule*/ { int tmp = cp; /*the tmp integer is used for swapping values, from the current cylinder position to the next*/ int ind = 0; for(i=0;i<=req;i++)/*this outer loops counts the number of requests*/ { for(j=0;j<req-i;j++) /*this inner loop walks through different values in the cylinder array which would later become sorted */ { if(cyposn[j] > cyposn[j+1])/*compares the two values previous position and the next position, if the previous is greater than the next position, the positions are swapped, taking the next position tobecome the current position a situation which would always ensure that the current position will become as small as possible: HENCE THE HANDLE WILL MOVE TO THE LEFT */ { temp = cyposn[j]; cyposn[j] = cyposn[j+1]; cyposn[j+1] = temp; } } } cp=0; /*when the loop finishes untill it finds the most minimal value: the handle is assigned to position '0' making the current position to be zero*/ do { if(cyposn[cp] == cposn) break; /*if it reaches the possible maximum cylinder value it breaks else it increments the values*/ cp++; }while(cp!=req); printf("\nS.No. Current Position Next Position Displacement \n"); printf("---------------------------------------------------------- \n\n"); i=0; cposn = cyposn[cp]; do { if(ind == 0) { if(cp == 0) { nposn = 0; ind = 1; } else nposn = cyposn[--cp]; } else { if(cp == 0) cp = tmp; nposn = cyposn[++cp]; } printf(" %d\t\t%d\t\t%d\t\t%d\n",++i,cposn,nposn,abs(cposn-nposn)); ttl_tracks += (abs(cposn-nposn)); cposn = nposn; }while(nposn!=cyposn[req]); printf("---------------------------------------------------------- \n\n"); printf(" Total Tracks Displaced : %d",ttl_tracks); } void main() { do { clrscr(); printf("\n Enter the number of requests : "); scanf("%d",&req); }while(req>max || req <=0); input(); SCAN(); getch(); } #包括 #包括 #包括 #定义最大值15 #定义cymax 249 int i,j,req,ttl_磁道=0,cp,np,cposn,nposn; 内部cyposn[max],温度; 无效输入() { 做 { clredol(); printf(“\n输入当前标题位置:”); scanf(“%d”和cposn); /*cposn当前气缸位置,在这种情况下是相同的 作为当前收割台位置*/ }而(cposn>cymax | | cposn,java,c++,c,operating-system,Java,C++,C,Operating System,您可以向硬盘驱动器发送命令。协议取决于您的硬盘驱动器 看看这些: 我建议您研究SATA、PATA和ATAPI协议。还可以搜索“Petzold写入设备驱动程序”.要进行系统编程,您需要指定您正在使用的特定系统。对于OSX、Windows等,答案会有所不同。好的,我正在使用Windows,更具体地说是Windows 7。我已经了解到Windows操作系统倾向于为程序员锁定内核,因此如果无法在wi中实现,那么ndows我甚至可以使用Linux特别是ubuntu 14。我只需要知道它是如何工作的,以

您可以向硬盘驱动器发送命令。协议取决于您的硬盘驱动器

看看这些:


我建议您研究SATA、PATA和ATAPI协议。还可以搜索“Petzold写入设备驱动程序”.

要进行系统编程,您需要指定您正在使用的特定系统。对于OSX、Windows等,答案会有所不同。好的,我正在使用Windows,更具体地说是Windows 7。我已经了解到Windows操作系统倾向于为程序员锁定内核,因此如果无法在wi中实现,那么ndows我甚至可以使用Linux特别是ubuntu 14。我只需要知道它是如何工作的,以及我自己如何编写一个代码来实际实现扫描磁盘调度算法。你知道,我认为现代硬盘不允许手动控制磁头。如果它们允许,你可能最好买一本书和大量磁盘来销毁它们请大家阅读,哈哈哈,书的名字,我愿意接受RISKI,一旦读到,使用某些C++,java,甚至C库,可以实际访问磁盘句柄,从而导致行为的方式……因此,实现扫描磁盘调度算法是可能的,因为SeSEI也进行了M的研究。我自己,我发现使用c库stdlib。在c中,一组函数允许你访问内存。这里的问题是如何实现磁盘调度算法,据我所知,大多数操作系统都是用c编写的,我需要的是得到它的实用性,在哪里磁盘调度算法在操作系统级别上,如果有C代码或C++或java代码,可以像MLDLC在STDLIB中访问内存的方式那样做,这将是非常有益的。