2013-04-22 167 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(而在同一時間跟蹤頭部位置)

 } 
    } 

回答