-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiskSchedulingAlgo.cpp
More file actions
50 lines (38 loc) · 1.32 KB
/
Copy pathdiskSchedulingAlgo.cpp
File metadata and controls
50 lines (38 loc) · 1.32 KB
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
//Programmer: Chau Nguyen
#include "constants.h"
#include "algorithms.cpp"
#include <iostream>
#include <random>
// #include <array>
#include <vector>
#include <algorithm>
int main()
{
//Create a pseudo random generator.
std::default_random_engine generator;
std::uniform_int_distribution<int> distribution(0, NUMBER_OF_CYLINDERS - 1);
std::vector<int> cylinderRequests(NUMBER_OF_REQUESTS);
//Generate a random series of 1,000 cylinder requests
for (size_t i = 0; i < NUMBER_OF_REQUESTS; ++i)
{
cylinderRequests[i] = distribution(generator);
}
//test
//std::cout << cylinderRequests[999] << " " << cylinderRequests[0] << std::endl;
//Print out the content of the vector
for(auto number: cylinderRequests)
{
std::cout << number << " ";
}
std::cout << std::endl;
//Prompt user for the head location
int head = 0;
std::cout << "Which cylinder is the head currently at? ";
std::cin >> head;
//Calculate head movements ()
//FCFS - First Come First Served
std::cout << "Running First-Come-First-Served Algorithm...\n" << FCFS(head, cylinderRequests) << std::endl;
//SSTF - Shortest Seek Time First
std::cout << "Running Shortest-Seek-Time-First Algorithm...\n" << SSTF(head, cylinderRequests) << std::endl;
return 0;
}