目前正在使用 bash 脚本并基于最短作业优先 (SJF) 进行循环。该循环不会重新循环以检查是否重新检查先前跳过的服务时间。我需要另一个循环和布尔值来检查吗?谢谢!
到达时间:服务时间
0:3
1:5
4:5
5:1
6:3
9:1
#execution of second process till last process of SPN
for (( i=1; i<array; i++ )); do
prevTime=${finishTime[$value]} #obtain value from previous completion time
curService=${serviceTime[$i]}
for (( j=i; j<array; j++ )); do
#compare previous completion time with current process.
if [[ $prevTime -ge ${arrivalTime[$j]} ]] && [[ $curService -ge ${serviceTime[$j]} ]]; then
curService=${serviceTime[$j]}
value=$j
fi
done
#calculation of each process finish & turnaround time
finishTime[$value]=`expr $prevTime + ${serviceTime[$value]}`
turnaroundTime[$value]=`expr ${finishTime[$value]} - ${arrivalTime[$value]}`
done