Question: Please write the code for the simple C program. Block Access Algorithms Make sure the program meets the following requirements: 1. Reads data from stdin,

Please write the code for the simple C program.

Block Access Algorithms

Make sure the program meets the following requirements:

1. Reads data from stdin, displays results in format as specified.

2. Displays proper results for the four block access alogrithms discussed.

In this assignment, you will be writing a program that reads a list of disk block access requests from stdin. That list will be used four times to run through the following block access algorithms:

First Come, First Served

Shortest Seek Time First

Non-circular LOOK

Circular LOOK

Your program will show the total seek values for each algorithm. The first value from the list is the last completed block request, and thus is the current block position for the device. Your program only needs to work with a maximum of 100 block requests.

Hints:

Most of these algorithms are simply two nested loops. The outer loop for each block request. The inner loop to search for the best selection for the next block request.

Make four functions, one for each algorithm. Pass the input data to each function as a parameter. Do not modify your original input arrays.

For each algorithm you will be calculating the difference between two block accesses and adding that difference to a total seek accumulator.

Remember that the difference is not just a simple subtraction. The difference must always be positive.

Output:

With this block access listPlease write the code for the simple C program. Block Access Algorithms, the output of your program should look like this:

block-list.txt

221

16

103

101

4

99

84

23

72

245

231

61

247

233

212

85

193

115

29

35

Output:

# ./assn7

All totals should be integer values. No floating point numbers necessary.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Here is a simple C program that performs the four block access algorithms as described c include include include define MAXBLOCKS 100 int absoluteDiff... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!