SlideShare a Scribd company logo
Please code the following in C
v. 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 processes Write 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 (1.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 block:Size by adding 1 to variable id
then modulus the total by the number of blocks g. Call function displayProcess passing arguments
allocation, processes, and processSize Write 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 (1.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. One-dimensional array, data type integer, contains the process sizes (i.e. processSize)
iv. Parameter contains the number of processes, data type integer (1.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. INTALID) 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 bestId x 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 processSize Write 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 wrtIdx 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 (1.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 process Size 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
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)

More Related Content

PDF
Need help with this assignment Please continue the code in .pdf
PDF
Need help with this assignment- Please continue the code in C programm.pdf
PDF
Please modify the following code in C Here is the initial c.pdf
PDF
Please modify the following code in C Make sure your code m.pdf
PDF
Please modify the following code in C. Make sure your code matches t.pdf
PDF
Write this in C language. This project will require students to si.pdf
PDF
c programing.Please help me with the write code libr.pdf
DOC
Need help with this assignment Please continue the code in .pdf
Need help with this assignment- Please continue the code in C programm.pdf
Please modify the following code in C Here is the initial c.pdf
Please modify the following code in C Make sure your code m.pdf
Please modify the following code in C. Make sure your code matches t.pdf
Write this in C language. This project will require students to si.pdf
c programing.Please help me with the write code libr.pdf

Similar to Please code the following in C v Write decision making l.pdf (20)

PDF
TLPI - 6 Process
DOCX
Operating system labs
PDF
Optimization Techniques
PDF
M.TECH 1ST SEM COMPUTER SCIENCE AOS LAB PRGMS 2014
PPT
DOC
Operating Systems lab Programs Algorithm - Fourth Semester - Engineering
PDF
Here is the code- I can't get it to work- I need a function that finds.pdf
TXT
Programs for Operating System
 
PPTX
UNIT 1.pptx Programming for Problem Solving
PDF
File organization
TXT
Bankers Algo Implementation
DOC
C - aptitude3
DOC
C aptitude questions
DOCX
UNIT-1.docx Design and Analysis of Algorithm
PDF
Compiler design.pdf
PDF
Embedded SW Interview Questions
PPT
Reduced instruction set computers
PPTX
Fortran & Link with Library & Brief Explanation of MKL BLAS
TLPI - 6 Process
Operating system labs
Optimization Techniques
M.TECH 1ST SEM COMPUTER SCIENCE AOS LAB PRGMS 2014
Operating Systems lab Programs Algorithm - Fourth Semester - Engineering
Here is the code- I can't get it to work- I need a function that finds.pdf
Programs for Operating System
 
UNIT 1.pptx Programming for Problem Solving
File organization
Bankers Algo Implementation
C - aptitude3
C aptitude questions
UNIT-1.docx Design and Analysis of Algorithm
Compiler design.pdf
Embedded SW Interview Questions
Reduced instruction set computers
Fortran & Link with Library & Brief Explanation of MKL BLAS
Ad

More from kitty811 (20)

PDF
please fix this code so that the tests pass css Selec.pdf
PDF
please help Below are the ages at which US presidents bega.pdf
PDF
please fill in the blanks below the proc structure .pdf
PDF
Please explain these steps Not sure how to go from first li.pdf
PDF
Please help Edgar Given the following API for a mutable Em.pdf
PDF
Please help 1 Use any data structures or control flows as a.pdf
PDF
Please graph the spectrum using only MATLAB and provide the .pdf
PDF
please help Let X and Y be random variables with joint dens.pdf
PDF
Please go through the Review Article and submit a summary of.pdf
PDF
Please give me a new topic not the one already on cheggQU.pdf
PDF
please give ANY inswer in 30 min The CONTROL pyloric rhythm .pdf
PDF
please full it please full it 2 Genie and Dan have just ha.pdf
PDF
Please find the Below YAML code whihc is meant to achieve th.pdf
PDF
Please fix my errors class Iterator public Construc.pdf
PDF
Please fill in the blanks of the 5 questions Required inform.pdf
PDF
please fast answer Suppose that XU nif 01 You draw a sa.pdf
PDF
Please explain in steps so I may be able to follow and learn.pdf
PDF
Please explain why c is correct Why does this return and e.pdf
PDF
Please code in C in Visual Studio Thank you 1 Create a C.pdf
PDF
Please explain step by step Current Attempt in Progress As .pdf
please fix this code so that the tests pass css Selec.pdf
please help Below are the ages at which US presidents bega.pdf
please fill in the blanks below the proc structure .pdf
Please explain these steps Not sure how to go from first li.pdf
Please help Edgar Given the following API for a mutable Em.pdf
Please help 1 Use any data structures or control flows as a.pdf
Please graph the spectrum using only MATLAB and provide the .pdf
please help Let X and Y be random variables with joint dens.pdf
Please go through the Review Article and submit a summary of.pdf
Please give me a new topic not the one already on cheggQU.pdf
please give ANY inswer in 30 min The CONTROL pyloric rhythm .pdf
please full it please full it 2 Genie and Dan have just ha.pdf
Please find the Below YAML code whihc is meant to achieve th.pdf
Please fix my errors class Iterator public Construc.pdf
Please fill in the blanks of the 5 questions Required inform.pdf
please fast answer Suppose that XU nif 01 You draw a sa.pdf
Please explain in steps so I may be able to follow and learn.pdf
Please explain why c is correct Why does this return and e.pdf
Please code in C in Visual Studio Thank you 1 Create a C.pdf
Please explain step by step Current Attempt in Progress As .pdf
Ad

Recently uploaded (20)

PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
Unit 4 Skeletal System.ppt.pptxopresentatiom
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
Cell Types and Its function , kingdom of life
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
1_English_Language_Set_2.pdf probationary
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PDF
advance database management system book.pdf
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Unit 4 Skeletal System.ppt.pptxopresentatiom
A systematic review of self-coping strategies used by university students to ...
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
Supply Chain Operations Speaking Notes -ICLT Program
Chinmaya Tiranga quiz Grand Finale.pdf
UNIT III MENTAL HEALTH NURSING ASSESSMENT
202450812 BayCHI UCSC-SV 20250812 v17.pptx
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Cell Types and Its function , kingdom of life
Final Presentation General Medicine 03-08-2024.pptx
1_English_Language_Set_2.pdf probationary
Computing-Curriculum for Schools in Ghana
Final Presentation General Medicine 03-08-2024.pptx
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Paper A Mock Exam 9_ Attempt review.pdf.
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
advance database management system book.pdf

Please code the following in C v Write decision making l.pdf

  • 1. Please code the following in C v. 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 processes Write 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 (1.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 block:Size by adding 1 to variable id then modulus the total by the number of blocks g. Call function displayProcess passing arguments allocation, processes, and processSize Write 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 (1.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. One-dimensional array, data type integer, contains the process sizes (i.e. processSize) iv. Parameter contains the number of processes, data type integer (1.e. processes) c. Declare a
  • 2. 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. INTALID) 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 bestId x 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 processSize Write 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 wrtIdx 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 (1.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 process Size 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 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.