Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- echo "Enter number of Process:"
- read n;
- echo "Enter Burst Time :"
- read b;
- for (( i = 0; i < n; i++ )); do
- echo "P$(($i+1)):"
- read bt[$i]
- p[$i]=$(($i+1))
- done
- # Sorting of burst time:
- for (( i = 0; i < n; i++ )); do
- pos=$i
- for (( j = i+1; j < n; j++ )); do
- if [[ bt[$j] -lt bt[$pos] ]]; then
- pos=$j
- fi
- done
- temp=$((bt[$i]))
- bt[$i]=$((bt[$pos]))
- bt[$pos]=$temp
- temp=$((p[$i]))
- p[$i]=$((p[$pos]))
- p[$pos]=$temp
- done
- wt[0]=0
- for (( i = 1; i < n; i++ )); do
- wt[$i]=0
- for (( j = 0; j < i; j++ )); do
- wt[$i]=$((wt[$i]+bt[$j]))
- done
- total=$(($total+wt[$i]))
- done
- avg_wt=$(($total/$n))
- total=0
- echo -e "Processt\tBurst Time\tWaiting Time\t Turnaround Time"
- for (( i = 0; i < n; i++ )); do
- tat[$i]=$((bt[$i]+wt[$i]))
- total=$(($total+tat[$i]))
- echo -e "${p[$i]}\t\t${bt[$i]}\t\t${wt[$i]}\t\t${tat[$i]}"
- done
- avg_tat=$((total/n))
- echo "Average Wating Time = $avg_wt"
- echo "Avg Turnaround Time = $avg_tat"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement