如何计算多核CPU的循环等待时间

时间:2013-03-26 01:21:25

标签: algorithm scheduling round-robin

我对多核心问题有疑问多Cpu RR仿真;我试图了解如何为多核和多CPU-RoundRobin仿真算法推导出WTime。     我想弄清楚这个假设是否正确?

#CPU => 2;
#Cores => 2;
#Processes => 6;
TQ = 5;
Process#    BurstTime
1           5
2           6
3           7
4           8
5           9
6           10


Process RR Algorithm Data       
Process#    BTime       WTime   CPU#
1           5           0       1
2           5           0       1
3           5           5       2
4           5           5       2
5           5           10      1
6           5           10      1
2           1           17      2
3           2           17      2
4           3           21      1
5           4           21      1
6           5           26      2
Is the this correct? Specifically P2 WTime?
P1 => 0
P2 => 17 - 0 = 17
P3 => 17 - (5*1) - 0 = 12
P4 => 21 - (5*1) - 0 = 16
P5 => 21 - (5*1) - 0 = 21
P6 => 26 - (5*1) - 0 = 21

计算流程的平均等待时间=> (0 + 17 + 12 + 16 + 21 + 21)/ 6

1 个答案:

答案 0 :(得分:0)

我假设您只有一个全局队列,总共有4个核心,核心被分配(如果多于一个空闲)从1/1到2/2,并且上下文切换时间为0:

Process #  core #  start  end  remaining    acc. waiting time  
1          1/1      0      5    0            0 *          
2          1/2      0      5    1            0       
3          2/1      0      5    2            0                
4          2/2      0      5    3            0
5          1/1      5      10   4            5
6          1/2      5      10   5            5
2          2/1      5      6    0            0=0+0*
3          2/2      5      7    0            0=0+0 * (core became idle)
4          2/1      6      9    0            1=0+1 * (core became idle)
5          1/1      10     14   0            5=5+0 *
6          1/2      10     15   0            5=5+0 *

*标志着最后累积的等待时间。