Question: Write function sjf to do the following a . Return type void b . Parameter list i . An array for the process IDs, data

Write function sjf to do the following
a. Return type void
b. Parameter list
i. An array for the process IDs, data type int (i.e., process)
ii. An array for the arrival times, data type int (i.e., at)
iii. An array for the burst times, data type int (i.e., bt)
c. Declare an array for the wait times, data type int (i.e., wt)
d. Declare an array for the turnaround times, data type int (i.e., tat)
e. Declare a variable for the current index for sorting (i.e., idx)
f. Declare a variable for temporary storage for sorting (i.e., temp)
g. Write a nested loop to sort the process data based on burst time
a. Outer loop iterates for the number of processes (i.e., PID)
i. Set variable idx to the current value of the outer
loop control variable
ii. Inner loop iterates for the number of processes (i.e.,
PID) with the loop control variable initialized to the
outer loop control variable plus 1
1. If the value in array bt, index of the inner
loop control variable, is less than the value
in array bt, index of variable idx
a. Set variable idx to the current value
of the inner loop control variable
iii. Swap the burst times
1. Set variable temp equal to array bt, index
of the outer loop control variable
2. Set the value of array bt, index of the outer
loop control variable, equal to array bt,
index of variable idx
3. Set the value of array bt, index of variable
idx, equal to variable temp
iv. Swap the process IDs
4
1. Set variable temp equal to array process,
index of the outer loop control variable
2. Set the value of array process, index of the
outer loop control variable, equal to array
process, index of variable idx
3. Set the value of array process, index of
variable idx, equal to variable temp
v. Swap the arrival times
1. Set variable temp equal to array at, index
of the outer loop control variable
2. Set the value of array at, index of the outer
loop control variable, equal to array at,
index of variable idx
3. Set the value of array at, index of variable
idx, equal to variable temp
h. Initialize index 0 in array wt to 0
i. Calculate the wait times for each process
i. Iterate for the number of processes (i.e., PID) starting at
index 1
1. Set the wait time in array wt at the current index
equal to the sum of burst time (i.e., bt) of the
previous index and wait time (i.e., wt) of the
previous index
j. Calculate the turnaround times for each process
i. Iterate for the number of processes (i.e., PID)
2. Set the turnaround time in array tat at the current
index equal to the sum of burst time (i.e., bt) of the
current index and wait time (i.e., wt) of the current
index
k. Call function displaySchedule passing arguments
i. Array process
ii. Array at
iii. Array bt
iv. Array wt
v. Array tat

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!