Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 . Write function sjf to do the following a . Return type void b . Parameter list i . An array for the process

1. 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 3 Lnai 8726

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448440, 978-3662448441

More Books

Students also viewed these Databases questions