Question: Please help me with my Operating systems assignment. This is the given STTF.java // A Java program to implement SSTF disk scheduling algorithm // program
Please help me with my Operating systems assignment.
This is the given STTF.java
// A Java program to implement SSTF disk scheduling algorithm
// program creater
// program complete date
import java.util.Arrays;
class node {
// "distance" is the difference(distance) between the head position and the target track number
// (a target track means that the track has a request on)
// "accessed" is true if a request on the current track
// (a current track means that the head is on the track now)
int distance = 0;
boolean accessed = false;
}
public class SSTF_uncomplete {
// "calculateDifference" calculates the difference (distance) between each target track number and the head position and saves the difference (distance) in each element of "diff[]"
// "queue[]" includes track numbers with requests on
// "head" is the head position (the current track number)
public static void calculateDifference(int queue[], int head, node diff[]){
// please complete this part
}
// "findMin" finds the index of the element with the minimum distance from the current track in the "diff[]"
public static int findMin(node diff[]){
int index = -1, minimum = Integer.MAX_VALUE;
for (int i = 0; i
if (!diff[i].accessed && minimum > diff[i].distance){
// please complete this part
}
}
return index;
}
public static void shortestSeekTimeFirst(int request[], int head){
node diff[] = new node[request.length];
for (int i = 0; i
diff[i] = new node();
// "seek_count" is the total seeking distance
int seek_count = 0;
// "seek_sequence" stores the seeking sequence
int[] seek_sequence = new int[request.length + 1];
for (int i = 0; i
// Complete the following part
}
// for the last accessed track
seek_sequence[seek_sequence.length - 1] = head;
System.out.println("Total seeking distance is " + seek_count);
System.out.println("The seeking sequence (include the original head position) is "+ Arrays.toString(seek_sequence));
}
public static void main(String[] args){
// request array
int arr[] = { 176, 79, 34, 60, 92, 11, 41, 114 };
// set the current head position as "50"
shortestSeekTimeFirst(arr, 50);
}
}
* If you answer as soon as possible, I will definitely press thumbs up.
Task A: Please complete the program (SSTF.java) to implement SSTF disk scheduling algorithm Requirement for Task A. 1. At the beginning of the program, in the comment part, add your name and the program complete date 2. There are a lot of comments in the program for helping to understand the fields and the methods C involved, read them carefully 3. Complete the methods "calculate Difference()", "find Min()", and "shortestSeekTimeFirst()" 4. The output results are expected as follows Total seeking distance is 204 The seeking sequence (include the original head position) is [50, 41, 34, 11, 60, 79, 92, 114, 176]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
