Skip to main content

Posts

Showing posts with the label scan algorithm

Write a simulation program for disk scheduling using SCAN algorithm. Accept total number of disk blocks, disk request string, direction of head movement and current head position from the user. Display the list of request in order which it is served. Also display the total number of head movements.

Write a simulation program for disk scheduling using SCAN algorithm. Accept total number of disk blocks, disk request string, direction of head movement and current head position from the user. Display the list of request in order which it is served. Also display the total number of head movements. Program: #include<stdio.h> #include<conio.h> #include <string.h> int main2(void){ setbuf(stdout,NULL); int n,i,pr[50],cp,th,max,small,temp; char d; printf("\n Enter number of disk blocks:"); scanf("%d",&n); printf("\n Enter the current position of head:"); scanf("%d",&cp); printf("Enter the String:"); for(i=0;i<n;i++){ scanf("%d",&pr[i]); } printf("\nEnter the direction of head movement:"); scanf(" %c",&d); max=pr[0]; small=pr[0]; for(i=1;i<n;i++){ if(pr[i]>max){ max = pr[i]; } if(pr[i]<small){ small = pr[i]; } } if(d=='l...