-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscheduler.h
118 lines (105 loc) · 4.26 KB
/
scheduler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
* Parker Riebs
* 5/10/2015
*
* Takes the number of disk cylinders in the disk, the head position of a
* hard drive, and a list of harddisk requests as inputs. Then, runs different
* algorithms, timing how long each takes to move across the platter of the
* hard drive.
* Algorithms: "First-come, first served (FCFS)", Shortest-seek-time-first (SSTF),
* SCAN, C-SCAN, LOOK, C-LOOK
*
* CS 441/541: Disk Algorithm Simulator (Project 6)
*/
#include <stdio.h>
/* For atoi */
#include <stdlib.h>
/* For String operations - strlen */
#include <string.h>
/* For isdigit */
#include <ctype.h>
/* For bool type */
#include <stdbool.h>
/******************************
* Defines
******************************/
// Maximum per-line length from the files
#define MAX_INPUT_LINE 1024
/******************************
* Structures
******************************/
/******************************
* Global Variables
******************************/
/******************************
* Function declarations
******************************/
/*
* Runs the First-Come-First-Serve algorithm for cylinder requests to find the
* seek time for the algorthithm based off a head position.
*
* Parameters:
* current_head_pos: The current position of the head on the cylinder.
* cylinder_req: The cylinder requests for the head to go to.
* num_cylinder_req: The number of cylinder requests.
*/
int first_come_first_serve(int current_head_pos, int * cylinder_req, int num_cylinder_req);
/*
* Runs the Shortest-Seek-Time-First algorithm for cylinder requests to find
* the seek time for the algorthithm based off a head position.
*
* Parameters:
* current_head_pos: The current position of the head on the cylinder.
* num_cylinder: The number of disk cylinders.
* cylinder_req: The cylinder requests for the head to go to.
* num_cylinder_req: The number of cylinder requests.
*/
int shortest_seek_time_first(int current_head_pos, int num_cylinder, int * cylinder_req, int num_cylinder_req);
/*
* Runs the SCAN (Elevator) algorithm for cylinder requests to find the seek
* time for the algorthithm based off a head position.
*
* Parameters:
* current_direction: The current direction of the head.
* current_head_pos: The current position of the head on the cylinder.
* num_cylinder: The number of disk cylinders.
* cylinder_req: The cylinder requests for the head to go to.
* num_cylinder_req: The number of cylinder requests.
*/
int scan_elevator(int current_direction, int current_head_pos, int num_cylinder, int * cylinder_req, int num_cylinder_req);
/*
* Runs the CSCAN algorithm for cylinder requests to find the seek time for the
* algorthithm based off a head position.
*
* Parameters:
* current_direction: The current direction of the head.
* current_head_pos: The current position of the head on the cylinder.
* num_cylinder: The number of disk cylinders.
* cylinder_req: The cylinder requests for the head to go to.
* num_cylinder_req: The number of cylinder requests.
*/
int c_scan_elevator(int current_direction, int current_head_pos, int num_cylinder, int * cylinder_req, int num_cylinder_req);
/*
* Runs the LOOK algorithm for cylinder requests to find the seek time for the
* algorthithm based off a head position.
*
* Parameters:
* current_direction: The current direction of the head.
* current_head_pos: The current position of the head on the cylinder.
* num_cylinder: The number of disk cylinders.
* cylinder_req: The cylinder requests for the head to go to.
* num_cylinder_req: The number of cylinder requests.
*/
int look_algorithm(int current_direction, int current_head_pos, int num_cylinder, int * cylinder_req, int num_cylinder_req);
/*
* Runs the CLOOK algorithm for cylinder requests to find the seek time for the
* algorthithm based off a head position.
*
* Parameters:
* current_direction: The current direction of the head.
* current_head_pos: The current position of the head on the cylinder.
* num_cylinder: The number of disk cylinders.
* cylinder_req: The cylinder requests for the head to go to.
* num_cylinder_req: The number of cylinder requests.
*/
int clook_algorithm(int current_direction, int current_head_pos, int num_cylinder, int * cylinder_req, int num_cylinder_req);