Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please assist as soon as possible!!!! WIll upvote if correct - C programming only (NOT C++) - Refer to the rubric/guidelines - Please ensure the

Please assist as soon as possible!!!! WIll upvote if correct

- C programming only (NOT C++)

- Refer to the rubric/guidelines

- Please ensure the expected output is achieved

-Please include the entire,full,updated,and modified code

- Please see all parts

Part 1:

********DELIVERABLES TO CODE********

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
Tasks Activity OSManagement.c 1. Update source code file OSManagement.c preprocessor 2. Add function prototype for functions a. memoryManagement b. displayProcess c. firstFit d. worstFit e. bestFit f. nextFit main 3. Update the main function to do the following a. Update decision making logic to determine which OS function to run based on the following a. 1 = call function memoryManagement memoryManagement 4. Write function memoryManagement to do the following a. Return type void b. Empty parameter list c. Call function clearScreen d. Write a looping construct to loop for each of the four memory management algorithms i. Declare a one-dimensional array, data type integer, to store the sizes of the memory blocks (i.e. blockSize) initialized with values 80, 10, 65, 35, 70 ii. Declare a one-dimensional array, data type integer, to store the sizes of the processes (i.e. processSize) initialized with values 25, 70, 5, 45, 60 iii. Declare a variable, data type integer, to store the number of blocks (i.e. blocks) iv. Declare a variable, data type integer, to store the number of processes (i.e. processes)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 rstFit, passing arguments blockSize, blocks, processSize, and processes . When algorithm is equal to BEST, call function bestFit, passing arguments blockSize, blocks, processSize, and processes . When algorithm is equal to WORST, call function worstFit, passing arguments hlockSize, blocks, processSize, and processes . When algorithm is equal to NEXT, call function nextFit, passing arguments blockSize, blocks, urocessSize, and I rocesses 5. 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) . 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) . 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 . Declare a variable, data type integer, to store the block allocation for a process, initialize to 0 (i.e. id) . Call mction memset, passing arguments i. Array allocation ii. -1 (i.e. INVALID) iii. sizeoallocation) 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. lfthe current block size (i.e. index id) is greater than or equal to the current process size (i.e. index of outer looping variable) 3. Update the allocation array to set the element at index of the outer looping variable equal to variable id . Reduce available memory of the current block size (i.e. index id b the urocess size (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 displayProccss passing arguments allocation, rocesscs, and IrocessSize 6. Write function rstFit 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) 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) . 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 Call function memsct, passing arguments i. Array allocation ii. -1 (i.e. INVALID) iii. sizeof(allocation) . 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 . Reduce available memory of the current block size (i.e. index of the inner looping valiable) by the process size (i.e. index of the outer looping variable) c. break out of the inner loop f. Call function displayProccss passing arguments allocation, rocesscs, and IrocessSize bestFit 7. Write 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 (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 bestldx) by the process size (i.e. index of the outer looping variable) f. Call function displayProcess passing arguments allocation, .rocesses and rocessSize 8. Write function worstFit to do the following a. Rettun 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) 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) Declare a one-dimensional array, data type integer, to store the block id that a process is allocated to (Le. allocation), size is parameter processes . Call function memset, passing arguments i. Array allocation ii. -1 (Le. INVALID) iii. sizeoallocation) Using a looping construct, loop through the number of processes i. Declare a variable, data type integer, to store the current worst t value (i.e. wstldx) 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 -l (i.e. INVALID) i. Set variable wstldx equal to the current block (i.c. the inner looping variable) b. Else if the value of the block size at index wstldx is less than the value of the block size at index of the inner looping variable i. Set variable wstldx equal to the current block (i.e. the inner loo in_ variable iii. If the value of variable wstldx is not equal to -l (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 wstldx) by the process size (i.e. index of the outer looping variable) f. Call function displayProcess passing arguments allocation, recesses, and urocessSize displayProcess 9. Write function displayProcess to do the following a. Return type void b. Parameter list includes 1. 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 (Le use the looping variable plus 1) Display to the console the process size (i.e. processSize array at the current looping index) 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 . Else, output the current allocation (i.e. allocation) executable Test Case 3 Test Case 3 asses Test Case 6 Test Case 6 asses Source com-iles with no errors Source comiles with no wmin-s Source runs with no errors inxxxxxxxxxx> Memory Management xxxxxxxxx xxxxxxxx** First Fit *xxxxxxxxx Process No. Process Size Block no. 25 70 UIDWNA 5 45 60 W XXXXXXxxx Best Fit **xxxxxxxx Process No. Process Size Block no. 25 70 UI AWNP 5 HWNUD 45 60 **** Worst Fit *xxxxxxxxx Process No. Process Size Block no. 25 70 5 UISWNA 5 3 45 3 60 Not allocated Next Fit * *xxxxxxxx Process No. Process Size Block no. 25 70 5 UI PAWNH 5 1 45 60 W Figure 2 memoryManagement function outputPerform the following test cases Test Cases Action Expected outcome Test Case 1 Run executable The executable runs The output in the command prompt should be similar to Error! Reference source not found. Test Case 2 User enters an invalid The output in the command prompt should menu option value, be similar to Error! Reference source not value 2, or value 3 found. Test Case 3 User enters menu The output in the command prompt should option value 1; be similar to Figure 2 memoryManagement memoryManagement function output function Test Case 4 User enters menu The output in the command prompt should option value 1; be similar to Figure 3 nextFit function output nextFit function Test Case 5 User enters menu The output in the command prompt should option value 1; be similar to Figure 4 firstFit function output firstFit function Test Case 6 User enters menu The output in the command prompt should option value 1; be similar to Figure 5 bestFit function output bestFit function Test Case 7 User enters menu The output in the command prompt should option value 1; be similar to Figure 6 worstFit function worstFit function output Test Case 8 User enters menu End of functionality; option value 0Operating System Management Menu Select the OS program to run, enter the number of your selection. 1. Memory Management 2. File Management 3. Multithreading 0. Exit Figure 1 displayMenu function outputxx#*****#* Next Fit *#**x#x** Process No. Process Size Block no. 1 25 76 5 45 66 Figure 3 nextFit function output :**#*##*** First Fit #*t**x#*## Process No. Process Size 1 25 76 5 45 60 Figure 4 rstFit function output ##++++x*t Best Fit #+t*#++*+ Process No. Process Size Block no. 1 25 2 79 3 5 4 45 5 so Figure 5 bestFit function output Process No. Process Size Block no. 1 25 1 76 5 5 3 2 3 4 45 3 5 so Not allocated Figure 6 worstFit function output i. NEXT as value 3 4. Function prototype for functions a. displayMenu b. clearScreen main 5. Write the main function to do the following a. Return type int b. Empty parameter list c. Declare a variable, data type integer, to store the user's menu selection (i.e. choice), initialized to -1 d. Write a loop to continue while variable choice is not equal to 0 a. Set variable choice equal to function call displayMenu b. Use decision making logic to determine which OS function to run based on the following i. 1 = memoryManagement- TBD; do nothing for this assignment ii. 2 = fileManagement - TBD; do nothing for this assignment iii. 3 = multiThreads - TBD; do nothing for this assignment iv. 0 = call function exit() passing 0 as an argument e. Exit the program by returning 0 displayMenu 6. Write function displayMenu to do the following a. Return type int b. Empty parameter list c. Declare a variable, data type integer, to store the user's menu selection (i.e. choice), initialized to -1 d. Write a loop to continue while variable choice is equal to -1 i. Write a series of printf statements to display the OS Management Menu ii. Prompt the user to enter their menu selection, store the input in variable choice iii. Use decision making logic to validate the user's input is between values 0 and 3; if not, set variable choice equal to -1 e. Return variable choice clearScreen 7. Write function clearScreen to do the following a. Return type void b. Empty parameter list c. Outputs to the screen using a call of function printf to prompt the user to hit the enter key to move on to the next screen as shown in Error! Reference source not found. d. Declare a variable of data type char e. Call function scanf to store input in the char variable f. Call function system passing argument explicit text "cls" g. Call function system passing argument explicit text "clear"3 h. If your operating system is Windows, comment out the second call to function system with argument "cls" i. If your operating system is Mac or Linux, comment out the first call to function system with argument "clear" OSManagement executable Test Case 1 Test Case 1 passes Test Case 2 Test Case 2 passes Test Case 3 | Test Case 3 passes Source compiles with no errors Source compiles with no warnings Source runs with no errors Source includes comments Perform the following test cases Test Cases Action Expected outcome Test Case 1 Run executable The executable runs The output in the command prompt should be similar to Figure 1 Test Case 2 User enters menu The output in the command prompt should option value 1, value be similar to Figure 1 2, or value 3 Test Case 3 User enters menu End of functionality option value 0 ********** Operating System Management Menu ********** Select the OS program to run, enter the number of your selection. Memory Management File Management Multithreading Exit Figure 1 displayMenu function outputTasks Activity OSManagement.c 1. Create source code file OSManagement.c preprocessor 2. Include the following C libraries a. stdio.h b. stdlib.h c. string.h 3. Declare the following macros (a.k.a. global constants) a. EXIT as value 0 b. INVALID as value -1 c. MEMORY as value 1 d. FILES as value 2 e. THREAD as value 3 f. FIRST as value 0 g. BEST as value 1 h. WORST as value 2

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

Analyze risky decisions using a decision tree.

Answered: 1 week ago