我正在尝试编写 CLOOK 调度算法,但我对如何前进有点迷茫。这是我所拥有的
queue<int> workQ;
int headPosition;
int temp;
int cyl;
cout << "Enter the number of cylinders: ";
cin >> cyl;
cout << "Please enter the head Position: " ;
cin >> headPosition;
cout << "Enter the request: ";
while(true)
{
cin >> temp;
//Enter a '0' to signal the end of inputing request
if(temp == 0)
{
break;
}
//Will implement check later to make sure the request is not greater than the number of cylinder
workQ.push(temp);
}
//Print content of Queue AND put into a vector
queue<int> tempQ;
vector<int>request;
tempQ = workQ;
while(!tempQ.empty())
{
cout << tempQ.front() << " ";
//Put in vector for easier use
request.push_back(tempQ.front());
tempQ.pop();
}
cout << endl;
queue<int> clook; // used to hold the order of the request after scheduling is complete
//starting the CLOOK algorithm with the head set at 50 by user
//for(int i = 0 ; i < request.size() ; i++)
//{}
int max;
int min;
//I didnt include the insertion Sort code but it works fine
insertionSort(request, max, min);
cout << max << endl;
cout << min << endl;
while(!request.empty())
for(int i = 0 ; i < request.size(); i++)
{
// I am lost on how to go forward here!!
磁头位置为50,柱面数为200。工作请求如下[95,180,34,119,11,123,62,64],排序后得到[11,34,62,64,95,119,123,180]。我基本上想从 50 开始磁头,这意味着 CLOOK 调度应该服务于 34,11 并跳转到 180,然后是 123,119,95,64,62(同时跟踪磁头位置)
}
}