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

128,022

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.

Share:
128,022
Marco Pietro Cirillo
Author by

Marco Pietro Cirillo

Lead Developer at Code4Armour

Updated on July 11, 2022

Comments

  • Marco Pietro Cirillo
    Marco Pietro Cirillo almost 2 years

    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!