Calculating Waiting Time and Turnaround Time in (non-preemptive) FCFS queue

后端 未结 2 1646
孤城傲影
孤城傲影 2020-12-30 14:46

I have 6 processes as follows:

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

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

-- P2 --
  arrival time         


        
相关标签:
2条回答
  • 2020-12-30 15:34

    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.

    0 讨论(0)
  • 2020-12-30 15:35
    wt = tt - cpu tm.
    Tt = cpu tm + wt.
    

    Where wt is a waiting time and tt is turnaround time. Cpu time is also called burst time.

    0 讨论(0)
提交回复
热议问题