Need help with this assignment. Please continue the code in C programming language. My current
code is below. You are supposed to build upon this code. Instructions are under the pics of the
code:
Tasksv. Write decision making logic based on the value of the looping variable (i.e. algorithm) 1.
When algorithm is equal to FIRST, call function firstFit, passing arguments blockSize, blocks,
processSize, and processes 2. When algorithm is equal to BEST, call function bestFit, passing
arguments blockSize, blocks, processSize, and processes 3. When algorithm is equal to WORST,
call function worstFit, passing arguments blockSize, blocks, processSize, and processes 4. When
algorithm is equal to NEXT, call function nextFit, passing arguments blockSize, blocks,
processSize, and processesWrite function nextFit to do the following a. Return type void b.
Parameter list includes i. One-dimensional array, data type integer, contains the block sizes (i.e.
blockSize) ii. Parameter contains the number of blocks, data type integer (i.e. blocks) iii. One-
dimensional array, data type integer, contains the process sizes (i.e. processSize) iv. Parameter
contains the number of processes, data type integer (i.e. processes) c. Declare a one-dimensional
array, data type integer, to store the block id that a process is allocated to (i.e. allocation), size is
parameter processes d. Declare a variable, data type integer, to store the block allocation for a
process, initialize to 0 (i.e. id) e. Call function memset, passing arguments i. Array allocation ii. -1
(i.e. INVALID) iii. sizeof(allocation) f. Using a looping construct, loop through the number of
processes i. Using a looping construct, loop while id is less than the number of blocks 1. If the
current block size (i.e. index id) is greater than or equal to the current process size (i.e. index of
outer looping variable) a. Update the allocation array to set the element at index of the outer
looping variable equal to variable id b. Reduce available memory of the current block size (i.e.
index id) by the processsize (i.e. index of the outer looping variable) c. break out of the inner loop
ii. Update the value of variable id to set the next index in array blockSize by adding 1 to variable id
then modulus the total by the number of blocks g. Call function displayProcess passing arguments
allocation, processes, and processSizeWrite function firstFit to do the following a. Return type void
b. Parameter list includes i. One-dimensional array, data type integer, contains the block sizes (i.e.
blockSize) ii. Parameter contains the number of blocks, data type integer (i.e. blocks) iii. One-
dimensional array, data type integer, contains the process sizes (i.e. processSize) iv. Parameter
contains the number of processes, data type integer (i.e. processes) c. Declare a one-dimensional
array, data type integer, to store the block id that a process is allocated to (i.e. allocation), size is
parameter processes d. Call function mem.
Need help with this assignment Please continue the code in .pdf
1. Need help with this assignment. Please continue the code in C programming language. My current
code is below. You are supposed to build upon this code. Instructions are under the pics of the
code:
Tasksv. Write decision making logic based on the value of the looping variable (i.e. algorithm) 1.
When algorithm is equal to FIRST, call function firstFit, passing arguments blockSize, blocks,
processSize, and processes 2. When algorithm is equal to BEST, call function bestFit, passing
arguments blockSize, blocks, processSize, and processes 3. When algorithm is equal to WORST,
call function worstFit, passing arguments blockSize, blocks, processSize, and processes 4. When
algorithm is equal to NEXT, call function nextFit, passing arguments blockSize, blocks,
processSize, and processesWrite function nextFit to do the following a. Return type void b.
Parameter list includes i. One-dimensional array, data type integer, contains the block sizes (i.e.
blockSize) ii. Parameter contains the number of blocks, data type integer (i.e. blocks) iii. One-
dimensional array, data type integer, contains the process sizes (i.e. processSize) iv. Parameter
contains the number of processes, data type integer (i.e. processes) c. Declare a one-dimensional
array, data type integer, to store the block id that a process is allocated to (i.e. allocation), size is
parameter processes d. Declare a variable, data type integer, to store the block allocation for a
process, initialize to 0 (i.e. id) e. Call function memset, passing arguments i. Array allocation ii. -1
(i.e. INVALID) iii. sizeof(allocation) f. Using a looping construct, loop through the number of
processes i. Using a looping construct, loop while id is less than the number of blocks 1. If the
current block size (i.e. index id) is greater than or equal to the current process size (i.e. index of
outer looping variable) a. Update the allocation array to set the element at index of the outer
looping variable equal to variable id b. Reduce available memory of the current block size (i.e.
index id) by the processsize (i.e. index of the outer looping variable) c. break out of the inner loop
ii. Update the value of variable id to set the next index in array blockSize by adding 1 to variable id
then modulus the total by the number of blocks g. Call function displayProcess passing arguments
allocation, processes, and processSizeWrite function firstFit to do the following a. Return type void
b. Parameter list includes i. One-dimensional array, data type integer, contains the block sizes (i.e.
blockSize) ii. Parameter contains the number of blocks, data type integer (i.e. blocks) iii. One-
dimensional array, data type integer, contains the process sizes (i.e. processSize) iv. Parameter
contains the number of processes, data type integer (i.e. processes) c. Declare a one-dimensional
array, data type integer, to store the block id that a process is allocated to (i.e. allocation), size is
parameter processes d. Call function memset, passing arguments i. Array allocation ii. -1 (i.e.
INVALID) iii. sizeof(allocation) e. Using a looping construct, loop through the number of processes
i. Using a looping construct, loop the number of blocks 1. If the current block size (i.e. index of the
inner looping variable ) is greater than or equal to the current process size (i.e. index of outer
looping variable) a. Update the allocation array to set the element at index of the outer looping
variable equal to the inner looping variable b. Reduce available memory of the current block size
(i.e. index of the inner looping variable) by the process size (i.e. index of the outer looping
variable) c. break out of the inner loop f. Call function displayProcess passing arguments
allocation, processes, and processSizeWrite function bestFit to do the following a. Return type
void b. Parameter list includes i. One-dimensional array, data type integer, contains the block
sizes (i.e. blockSize) ii. Parameter contains the number of blocks, data type integer (i.e. blocks) iii.
2. One-dimensional array, data type integer, contains the process sizes (i.e. processSize) iv.
Parameter contains the number of processes, data type integer (i.e. processes) c. Declare a one-
dimensional array, data type integer, to store the block id that a process is allocated to (i.e.
allocation), size is parameter processes d. Call function memset, passing arguments i. Array
allocation ii. -1 (i.e. INVALID) iii. sizeof(allocation) e. Using a looping construct, loop through the
number of processes i. Declare a variable, data type integer, to store the current best fit value (i.e.
bestIdx) initialized to -1 (i.e. INVALID) ii. Using a looping construct, loop the number of blocks 1. If
the current block size (i.e. index of the inner looping variable ) is greater than or equal to the
current process size (i.e. index of outer looping variable) a. If the value of bestIdx is equal to -1
(i.e. INVALID) i. Set variable bestIdx equal to the current block (i.e. the inner looping variable) b.
Else if the value of the block size at index bestIdx is greater than the value of the block size at
index of the inner looping variable i. Set variable bestidx equal to the current block (i.e. the inner
looping variable) iii. If the value of variable bestIdx is not equal to -1 (i.e. INVALID) 1. Update the
allocation array to set the element at index of the outer looping variable equal to variable bestIdx2.
Reduce available memory of the current block size (i.e. index bestIdx) by the process size (i.e.
index of the outer looping variable) f. Call function displayProcess passing arguments allocation,
processes, and processSizeWrite function worstFit to do the following a. Return type void b.
Parameter list includes i. One-dimensional array, data type integer, contains the block sizes (i.e.
blockSize) ii. Parameter contains the number of blocks, data type integer (i.e. blocks) iii. One-
dimensional array, data type integer, contains the process sizes (i.e. processSize) iv. Parameter
contains the number of processes, data type integer (i.e. processes) c. Declare a one-dimensional
array, data type integer, to store the block id that a process is allocated to (i.e. allocation), size is
parameter processes d. Call function memset, passing arguments i. Array allocation ii. -1 (i.e.
INVALID) iii. sizeof(allocation) e. Using a looping construct, loop through the number of processes
i. Declare a variable, data type integer, to store the current worst fit value (i.e. wstIdx) initialized to
-1 (i.e. INVALID) ii. Using a looping construct, loop the number of blocks 1. If the current block size
(i.e. index of the inner looping variable ) is greater than or equal to the current process size (i.e.
index of outer looping variable) a. If the value of wstIdx is equal to -1 (i.e. INVALID) i. Set variable
wstIdx equal to the current block (i.e. the inner looping variable) b. Else if the value of the block
size at index wstIdx is less than the value of the block size at index of the inner looping variable i.
Set variable wstIdx equal to the current block (i.e. the inner looping variable)iii. If the value of
variable wstIdx is not equal to -1 (i.e. INVALID) 1. Update the allocation array to set the element at
index of the outer looping variable equal to variable wstIdx 2. Reduce available memory of the
current block size (i.e. index wstIdx) by the process size (i.e. index of the outer looping variable) f.
Call function displayProcess passing arguments allocation, processes, and processSize Write
function displayProcess to do the following a. Return type void b. Parameter list includes i. One-
dimensional array, data type integer, that stores the block number allocations (i.e. allocation) ii.
Parameter that contains the number of processes, data type integer (i.e. processes) iii. One-
dimensional array, data type integer, that stores the processes (i.e. processSize) c. Write a
looping construct to loop through the processes (i.e. processSize) i. Display to the console the
process number (i.e use the looping variable plus 1 ) ii. Display to the console the process size
(i.e. processSize array at the current looping index) iii. Display to the console the memory block
3. assigned based on the following logic 1. If the value stored at the current index of array
processSize if -1 (i.e. INVALID), output Not Allocated 2. Else, output the current allocation (i.e.
allocation)Select the OS program to run, enter the number of your selection. 1. Memory
Management 2. File Management 3. Multithreading 0 . ExitFigure 2 memoryManagement function
outputFigure 3 nextFit function output ********** First Fit ********** Figure 4 firstFit function
outputFigure 5 bestFit function outputFigure 6 worstFit function output