Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include #include / / declare structure to store block information ( id , starting address, ending address, link to next block ) / / declare
#include
#include
declare structure to store block information id starting address,
ending address, link to next block
declare linked list to connect allocation block
declare global variables
void "OPTION #
declare local variables if any
prompt for size of physical memory and choice of holefitting
algorithm firstfit, bestfit initialize remaining memory
initilize linked list with "dummy" block of size
return;
void "PROCEDURE TO PRINT ALLOCATION TABLE"
declare local variables
print table containing block id starting address, ending address
return;
void "OPTION #
declare local variables
initialize best hole so far to size of physical memory
prompt for block id & block size
check if size of block is larger than remaining unallocated
space, if so print message and return
allocate space for new block and set id
if only "dummy" block exists, insert block at end of linked list,
set fields, return
else traverse list until either appropriate hole is found or the
end of the list is reached
if id already exists, reject request and return
set values for start and end of currently found hole
if hole is large enough for block
if firstfit algorithm
set start & end fields of new block
& add block into linked list
reduce remaining available memory
and return
elsebestfit algorithm
if hole is smaller than best so far
set values of best start
& best end & best hole size so far
update best block &
advance next block
set start & end fields of new block & add block into linked list
reduce remaining available memory and return
return;
void "OPTION #
declare local variables
prompt for block id
until end of linked list is reached or block id is found
traverse list
if end of linked list reached, print block id not found
else remove block and deallocate memory
return;
void "OPTION #
declare local variables
until end of list is reached
calculate current hole size
adjust start & end fields of current block to
eliminate hole
return;
void "OPTION #parametertype node
if node is NULL, return
else
recursively call procedure on nodelink
deallocate memory from node
return;
int main
declare local vars
while user has not chosen to quit
print menu of options
prompt for menu selection
call appropriate procedure based on choiceuse switch
statement or series of if else if else statements
while loop
return ; indicates success
end of procedure
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started