在FCFS算法中计算吞吐量

时间:2015-02-26 20:42:51

标签: c++ algorithm scheduling scheduler throughput

嘿伙计们我正在尝试计算C ++中FCFS算法的以下指标:等待时间,周转时间,响应时间,包括平均值和吞吐量。除了吞吐量之外,我已成功使用我的程序确定所有指标。我不太确定如何检测哪些程序在给定值下完成了爆发。非常感谢任何帮助。

非常感谢!!

这是我到目前为止所得到的:

void FCFS(int process_num, int burst[], int arrival[], int throughput)
{
  int wait[10], turnaround[10], g[10];
  int wt = 0;
  int tat = 0;
  //setup                                                                                                                                                                 
  g[0]=0;

  cout << "Output for FCFS scheduling algorithm" << endl;
  //calculations                                                                                                                                                          
  for (int i = 0; i < 10; i++)
    g[i+1] = g[i] + burst[i];
  for (int i = 0; i < process_num; i++)
    {
          wait[i] = g[i] - arrival[i];
          turnaround[i] = g[i+1] - arrival[i];
          wt += wait[i];
          tat += turnaround[i];
        }
      //output                                                                                                                                                                
      cout << "\nProcess\t\tBurst Time\tArrival Time\tWait Time\tTurnaround Time";                                                                                               \
       for( int i = 0; i < process_num; i++)
        {
          cout << "\nP[" << i + 1 << "]" << "\t\t" << burst[i] << "\t\t" <<     arrival[i] << "\t\t" << wait[i] << "\t\t" << turnaround[i];
        }

      cout << "\n\nAverage Wait Time: " << wt/process_num;
      cout << "\nAverage Response Time: " << wt/process_num;
      cout << "\nAverage Turnaround Time: " << tat/process_num << endl;
     }

0 个答案:

没有答案