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 list, 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started