how to calculate the processing time?

吃可爱长大的小学妹 提交于 2019-12-13 07:31:12

问题


Processing times for 5 processes were given. how will I find out the minimum average waiting time the processes have to wait in order to get executed if TWO PROCESSORS are given.


回答1:


On any given processor, the total waiting time for an ordered set of processes taking time P1..PN to complete is the total of individual elapsed times multiplied by the number of waiting processes remaining:

    (N - 1)P1 + (N - 2)P2 + ... + PN-1.

This reveals that waiting time is hit by a multiple of the cost of earlier processes, with the consequence that we need to get shorter-running jobs over with as early as possible and minimise queue length. Say we sort the process durations and call them A, B, C, D, and E (the longest-running job). If we contrast the following prioritorisation:

Processor 1: A, B, C, D
Processor 2: E
Total waiting time: 3A + 2B + C

...with...

Processor 1: A, B, D
Processor 2: C, E
Total waiting time: 2A + B + C

We can clearly see the second configuration saves (A + B) total waiting time, and the benefit of distributing the jobs in a 3:2 split. Equally, the 2A + B + C formula can only be worse if we swapped D or E for any of A, B or C, as we know A <= B <= C <= D <= E.

There are only two alternative 3:2 permutations given D and E don't partake in the waiting time calculation (they will be denoted with X hereafter).

Processor 1: A, C, X
Processor 2: B, X
Total waiting time: 2A + C + B  [no change]

Processor 1: A, X
Processor 2: B, C, X
Total waiting time: A + 2B + C  [maybe worse as B>=A]

Thus, the optimal and equally satisfactory orderings are: ABX/CX and ACX/BX.




回答2:


Perform shortest job first scheduling.
Then find the average waiting time.



来源:https://stackoverflow.com/questions/5078710/how-to-calculate-the-processing-time

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!