2013-04-22 3 views
0

Я пытаюсь написать алгоритм планирования CLOOK, и я немного потерял, как идти вперед. Вот что у меня естьРеализация алгоритма планирования C++

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 (в то же время, сохраняя при этом положения головы)

 } 
    } 

ответ

0

Существует дюжина реализаций, доступных в сети, просто их Google. Например, http://ashbeecode.blogspot.ru/2011/05/c-look-disk-scheduling-algorithm.html

+0

непереданный код, который вы предоставили, имеет многочисленные ошибки при попытке его скомпилировать. Я понятия не имею, правильно ли оно – user1771695

Смежные вопросы