*Must be written in C only* Skeleton Code #include #include #include // Declare global v

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

*Must be written in C only* Skeleton Code #include #include #include // Declare global v

Post by answerhappygod »

*Must be written in C only*
Must Be Written In C Only Skeleton Code Include Stdio H Include Stdlib H Include Limits H Declare Global V 1
Must Be Written In C Only Skeleton Code Include Stdio H Include Stdlib H Include Limits H Declare Global V 1 (314.74 KiB) Viewed 28 times
Skeleton Code
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
// Declare global variables, including dynamic array to store
sequence of
traversed tracks
/*********************************************************/
void "OPTION #1"() {
// prompt for the sequence size
// allocate memory for the sequence of traversed tracks
// prompt for starting track, store in index 0
// prompt for sequence of tracks to seek, store in index 1 to
"sequence size-1"
return;
} // "OPTION #1"
/*********************************************************/
void "OPTION #2"() {
// declare local variables
// calculate total distance of traversed tracks
// print sequence of traversal
// print total distance of tracks traversed
return;
} // "OPTION #2"
/*********************************************************/
void "OPTION #3"() {
// declare local variables
// initialize current track and distance traversed to starting
track
// begin printing sequence of traversal
// until every track is traversed
// initilize shortest distance to INT_MAX
// for each track in sequence
// if not already traversed
//if distance to traverse is shorter
than current shortest distance
// set current shortest
distance and index of the track w/ shortest distance
// set "done" value for track w/shortest distance to 1
(mark as traversed)
// increment number of tracks that have been traversed
// update total distance traversed
//set current track to new position, print position
// print total distance traversed
return;
} // "OPTION #3"
/*********************************************************/
void "OPTION #4"() {
// declare local variables
//prompt for initial direction (0=descreasing, 1=increasing)
// initialize current track and distance traversed to starting
track
// begin printing sequence of traversal
// until every track is traversed
// initilize shortest distance to INT_MAX
// for each track in sequence
// if not already traversed
//if distance to traverse is shorter
than current shortest distance in the current direction
// set current shortest
distance and index of the track w/ shortest distance
// set flag that at
least one track was traversed
// if at least one track was traversed
// set "done" value for track w/shortest
distance to 1 (mark as traversed)
// increment number of traversed tracks
// update total distance traversed
//set current track to new position, print
position
// else change direction
// print total distance traversed
return;
} // "OPTION #4"
/*********************************************************/
void "OPTION #5"() {
// declare local variables
// initialize current track and number traversed to starting
track
// begin printing sequence of traversal
// until every track is traversed
// initilize shortest distance to INT_MAX
// for each track in sequence
// if not already traversed
//if distance to traverse is shorter
than current shortest distance and a positive value (only
increasing
direction)
// set current shortest
distance and index of the track w/ shortest distance
// set flag that at
least one track was traversed
// if at least one track was traversed
// set "done" value for track w/shortest
distance to 1 (mark as traversed)
// increment number of tracks that have been
traversed
// if largest track was reached
// update total distance traversed by
derementing by distance to track (subtracts distance from 0 to
track)
// reset "largest track" flag
// else
// update total distance traversed by
distance to track
//set current track to new position, print
position
// else (no track was traversed)
// update total distance by current track
(adds remaining distance before going back to 0)
// reset current track to 0 (loop back
around)
// set "end reached" flag to 1
// print total distance traversed
return;
} // "OPTION #5
/***************************************************************/

void "OPTION #6"() {
// if sequence is not NULL, free sequence
return;
} // "OPTION #6
/***************************************************************/

int main() {
/* declare local vars */
/* while user has not chosen to quit */
/* print menu of options */
/* prompt for menu selection */
/* call appropriate procedure based on choice--use switch
statement or series of if, else if, else statements */
} /* while loop */
return 1; /* indicates success */
} // main
Objective: To compare the performance of various disk scheduling algorithms: First-in-first-out (FIFO), Shortest-seek-time-first (SSTF), Scan, and C-Scan. . Specification: The program compares the disk scheduling algorithms: First-in-first-out (FIFO), Shortest- seek-time-first (STTF), Scan, and C-Scan in terms of traversing a set of tracks input by the user, and calculates the total distance of the tracks traversed. A menu controls the operations, and each choice calls the appropriate procedure, where the choices are: 1) Enter parameters 2) Calculate distance to traverse tracks using FIFO 3) Calculate distance to traverse tracks using SSTF 4) Calculate distance to traverse tracks using Scan 5) Calculate distance to traverse tracks using C-Scan 6) Quit program and free memory . Assignment: For a sequence of size m, a disk scheduling algorithm accepts a starting track followed by a sequence of m-1 integers, where each index value t is a request to seek track t. Each scheduling algorithm generates an ordering according to which the m-1 requests are serviced from the starting track, and calculates the distance of the tracks traversed. .
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply