文章
156
粉丝
195
获赞
0
访问
28.5k
1)
周转时间 = 完成时间 - 到达时间
带权周转时间 = 周转时间 / 运行时间
P1:周转 = 13 - 0 = 13,带权 = 13 / 5 = 2.6
P2:周转 = 5 - 2 = 3,带权 = 3 / 3 = 1.0
P3:周转 = 8 - 3 = 5,带权 = 5 / 2 = 2.5
P4:周转 = 15- 5 = 10,带权 = 10 / 4 = 2.5
P5:周转 = 7 - 6 = 1,带权 = 1 / 1 = 1.0
平均周转时间 = (13+ 3 + 5 + 10 + 1) / 5 = 32 / 5 = 5.4
平均带权周转时间 = (2.6+ 1.0 + 2.5 + 2.5 + 1.0) / 5 = 8.95 / 5 = 1.92
2)
semaphore mutex=1;//缓冲区互斥
semaphore empty=1;//缓冲区空闲空间
semaphore full_a=0;//缓冲区中数据A的数量
semaphore full_b=0;//缓冲区中数据B的数量
P1(){
while(1){
P(empty);
P(mutex);
生产A;
V(full_a);
V(mutex);
}
}
P2(){
while(1){
P(empty);
P(mutex);
生产B;
V(full_b);
V(mutex);
}
}
P3(){
while(1){
P(full_a);
P(mutex);
消费A;
V(empty);
V(mutex);
}
}
P4(){
while(1){
P(full_b);
P(mutex);
消费b;
V(empty);
V(mutex);
}
}
P5(){
while(1){
if(full_a==0&...
登录后发布评论
暂无评论,来抢沙发