Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement the C-SCAN disk scheduling algorithm in C showing the number of head movements needed. Below is a main function that takes an input file

Implement the C-SCAN disk scheduling algorithm in C showing the number of head movements needed. Below is a main function that takes an input file and the intial head position.

Here is an example:

cat inputfile.txt | ./a.out 53

Here is a sample input using the intial head position as 53:

98, 183, 37, 122, 14, 124, 65, 67 (the head movements should = 183 with a request queue of 0-199)

#include  #include  /* Assume no more than 1000 requests in the input file */ #define BUFSIZE 1000 /* Assume 5000 cylinders */ #define CYL 5000 /* Assume no requests will be longer than 80 characterse */ #define LINELEN 80 
int cscan(int initpos, int requests[], int nmemb) { return 0; } main(int argc, char* argv[])
{ char s[LINELEN]; int requests[BUFSIZE]; int count; int initpos; if (argc < 2) { printf("Usage: ./a.out initpos "); exit(1); } initpos = atoi(argv[1]); count=0; while (fgets(s, LINELEN, stdin)) requests[count++]=atoi(s); printf("C-SCAN: %d ", cscan(initpos, requests, count)); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What explains the fast growth of the four Asian Tigers?

Answered: 1 week ago

Question

true or false Methods can only take in one type of parameter.

Answered: 1 week ago