【问题标题】:Priority scheduling OS bash file优先调度 OS bash 文件
【发布时间】:2018-05-24 03:31:10
【问题描述】:

我正在尝试制作 bash 文件来计算优先算法进程的等待时间和平均等待时间。我不知道它有什么问题,我一直在 '}' 第 39 行附近说意外结束

    echo "Enter Number Of process"
read num
let id[$i]=$i+1
for((i=0;i<num;i++))
{
echo "Enter Burst Time For Process P$id[$i]"
read burst[$i]
}

for((i=0;i<num;i++))
{
echo "Enter Priority Time For Process P$id[$i]"
read priority[$i]
}

waiting[0]=0

for((i=0;i<num;i++))
{
for((j=0;j<num;j++))
{
if [ ${priority[$i]} > ${priority[$j]} ]
then
temp2=${priority[$i]}
priority[$i]=${priority[$j]}
priority[$j]=$temp2
temp=${arrival[$j]}
arrival[$i]=${arrival[$j]}
arrival[$j]=$temp
temp1=${burst[$i]}
burst[$i]=${burst[$j]}
burst[$j]=$temp1

}
let tot={burst[$i]}+$tot
echo "arrival[$i] priority[$i] burst[$i] $tot"

【问题讨论】:

  • 请看:shellcheck.net
  • 正确缩进代码有助于发现语法和逻辑错误。

标签: linux bash operating-system


【解决方案1】:

最后的forif 缺少它们的结束语句。在脚本末尾附近插入 fi}。 然后尝试shellcheck 解决剩余的错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-22
    • 2010-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多