计算等待时间和周转时间(非preemptive)先来先服务的队列时间、队列、先来、preemptive

2023-09-11 03:56:26 作者:不离不弃纯属欺骗

我有6个流程如下:

   -  P0  - 
  到达时间= 0
  突发时间= 10

 -  P1  - 
  到达时间= 110
  突发时间= 210

 -  P2  - 
  到达时间= 130
  突发时间= 70

 -  P3  - 
  到达时间= 130
  突发时间= 70

 -  P4  - 
  到达时间= 130
  突发时间= 90

 -  P5  - 
  到达时间= 130
  突发时间= 50
 

我如何计算的等待时间和周转时间为每个进程?该系统应是非preemptive(进程得到CPU的,直到它完成)。另外:有在这个系统中4个逻辑处理器

假设SYSTEMTIME是当前系统的运行时间,和arrivalTime是相对于这一点。即:0的arrivalTime是指当系统执行过程开始; 130的arrivalTime表示进程启动130个单位在系统启动后。

这是正确的: waitingTime =(SYSTEMTIME - arrivalTime)

我的推理认为这是 SYSTEMTIME - arrivalTime 是时间过程已经守候在先来先服务排队使用CPU

和为周转时间,我的想法是这样的: turnaroundTime = burstTime + waitingTime ,由于等待时间和突发时间应占总时间来完成这个过程。虽然再一次,我不知道如果我的直觉是正确的。

任何和所有的读数将大大AP preciated!

解决方案

对于非preemptive系统,

  waitingTime =的startTime  -  arrivalTime

turnaroundTime = burstTime + waitingTime = finishTime- arrivalTime
 
调度算法的评价指标 CPU利用率 系统吞吐量 周转时间 等待时间 响应时间

的startTime 的=时间在此过程中开始执行

finishTime 的=时间在此过程中完成执行

您可以跟踪系统经过的当前时间(timeElapsed )。分配所有处理器在开始一个进程,并执行直到最短过程完成执行。然后分配该处理器,其可自由地在队列中的下一个过程。这样做,直到队列为空的和的全部工序均由内部完成执行。此外,当一个进程开始执行,条记录的的startTime ,当完成后,记录其 finishTime (两者同 timeElapsed )。这样,你可以计算出你所需要的。

I have 6 processes as follows:

-- P0 --
  arrival time = 0 
  burst time = 10  

-- P1 --
  arrival time = 110 
  burst time = 210  

-- P2 --
  arrival time = 130 
  burst time = 70  

-- P3 --
  arrival time = 130 
  burst time = 70

-- P4 --
  arrival time = 130 
  burst time = 90

-- P5 --
  arrival time = 130 
  burst time = 50

How can I calculate the waiting time and turnaround time for each process? The system should be non-preemptive (the process gets the CPU until it's done). Also: there are 4 logical processors in this system.

Assume systemTime is the current systems uptime, and arrivalTime is relative to that. ie: an arrivalTime of 0 means the process starts when the system does; an arrivalTime of 130 means the process is started 130 units after the system starts.

Is this correct: waitingTime = (systemTime - arrivalTime) ?

My reasoning for thinking this is that systemTime - arrivalTime is the time the process has been waiting in the fcfs queue to use the CPU (or is this wrong?)

And for turnaround time, I was thinking something like: turnaroundTime = burstTime + waitingTime, since the waiting time and the burst time should be the total time to complete the process. Though once again I don't know if my intuition is correct.

Any and all readings would be greatly appreciated!

解决方案

For non-preemptive system,

waitingTime = startTime - arrivalTime

turnaroundTime = burstTime + waitingTime = finishTime- arrivalTime

startTime = Time at which the process started executing

finishTime = Time at which the process finished executing

You can keep track of the current time elapsed in the system(timeElapsed). Assign all processors to a process in the beginning, and execute until the shortest process is done executing. Then assign this processor which is free to the next process in the queue. Do this until the queue is empty and all processes are done executing. Also, whenever a process starts executing, recored its startTime, when finishes, record its finishTime (both same as timeElapsed). That way you can calculate what you need.