Given an array of disk track numbers and initial head position, our task is to find the total number of seek operations done to access all the requested tracks if Shortest Seek Time First (SSTF) is a disk scheduling algorithm is used. Shortest Seek Time First (SSTF) –. Once the disk arm reaches the end of that direction, it reverses the direction of scanning and executes all of the jobs arriving in its path. The SCAN scheduling algorithm is also commonly known as Elevator algorithm, and this algorithm has a very high throughput. It also reduces the response time variance compared to the SSTF algorithm. Program to implement SSTF disk scheduling algorithm /. Variable description: req - array for taking the request, index - array fo. Program for SSTF disk scheduling algorithm Prerequisite – Disk scheduling algorithms Given an array of disk track numbers and initial head position, our task is to find the total number of seek operations done to access all the requested tracks if Shortest Seek Time First (SSTF) is a disk scheduling algorithm.
SCAN Disk Scheduling algorithm Program in C++ language .
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 | usingnamespacestd; constintN=100005; intn; intdirection; intpositions[N]; voidscan(void) intmovement,best,index,complete; movement=0; while(complete<n) index=-1; if(direction1)best=INT_MAX; for(inti=0;i<n;i++) if(!done[i]) if(direction0&&positions[i]>best&&positions[i]<head) index=i; } if(direction1&&positions[i]<best&&positions[i]>head) index=i; } } if(index>=0) complete++; movement+=abs(head-best); } { } cout<<'Total Head Movement '<<movement<<' Cylindersn'; } intmain() cout<<'Initial Head Position: '; cin>>direction; cout<<'Queue Size: '; for(inti=0;i<n;i++)cin>>positions[i]; scan(); return0; /** 0 98 183 37 122 14 124 65 67 |
SSTF disk scheduling program in c++ language .
Sstf Disk Algorithm Coding Questions
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 | usingnamespacestd; constintN=100005; intn; intdone[N]; { for(inti=0;i<n;i++) index=0; { { shortest=abs(head-positions[k]); } done[index]=true; head=positions[index]; printf('Total Head Movement %d Cylindersn',movement); } intmain() cout<<'Initial Head Position: '; cin>>n; cout<<'Queue:n'; } 53 98 183 37 122 14 124 65 67 |