Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program in C++. Already implemented the GET_MEMORY and FREE_MEMORY algorithms in a Python program. I need help to make the program run. Comprehensive testing must

Program in C++. Already implemented the "GET_MEMORY" and "FREE_MEMORY" algorithms in a Python program. I need help to make the program run.

Comprehensive testing must be done for each algorithm. Following are sample run results for each: GET_MEMORY IS RUNNING Initial FSB list FSB# Location Size 1 7 4 2 14 10 3 30 20 . . . . . . Rover is 14 ---------------------------------------------------------------------------- Allocation request for 5 words Allocation was successful Allocation was in location 14 FSB# Location Size 1 7 4 2 19 5 3 30 20 . . . . . . Rover is 30 ---------------------------------------------------------------------------- Allocation request for 150 words Allocation was not successful . . . __________________________________________________________ FREE_MEMORY IS RUNNING.. Initial FSB list FSB# Location Size 1 7 4 2 19 5 3 30 20 . . . . . . Rover is 30 ---------------------------------------------------------------------------- De-allocation request of 4 words at location 3 FSB# Location Size 1 3 8 2 19 5 3 30 20 . . . . . . Rover is 30 ----------------------------------------------------------------------------

==========================================================================

image text in transcribedimage text in transcribed

Begin GET MEMORY Allocate space from a list of FSBs using the first fit-with-a-roving-pointer technique Input SIZE of area desired (must be two or more words) - SCB containing the FSB head node as defined in Figure 2-7 Output STATUS of the GET_MEMORY operation - LOCATION of the area, if allocation is successful FSB list structure is modified Assume Minimum allocation of two words in order that a returned area may be structured into an FSB (see Algorithm 2-2) Default STATUS to failure Initialize PREVIOUS pointer to ROVER from the head node Do Set CURRENT to link(PREVIOUS) If the current block is adequate, i.e., size(CURRENT) Then [ Allocate space from the current block ] SIZE or size(CURRENT) SIZE2 Set LOCATION to the last SIZE words of the block, i.e., to CURRENT size(CURRENT) - SIZE If all of the block is needed, i.e., LOCATION = CURRENT Then [ Delink the FSB from the list ] Else I Shorten the FSB ] EndIf Save a new roving-pointer value in the head node, i.e., set ROVER Change STATUS to success Advance PREVIOUS to CURRENT to continue searching Set link(PREVIOUS) to link(CURRENT) Decrement size(CURRENT) by SIZE to PREVIOUS Else EndIf Until an area is allocated or the list is exhausted, i.e., STATUS success or CURRENT- ROVER EndDo End GET_MEMORY Algorithm 2-1 First-Fit-with-a-Roving-Pointer Allocatiorn be validated. The normal action upon detection of incorrect conditions is to abort execution of the calling process Code to validate the input SIZE is essential. In addition, when the tests for adjacency with neighboring blocks are made, the FREE MEMORY routine should also test for overlapping blocks; that is, does the new area extend beyond the starting address of the successor or begin before the end of the predecessor? Begin GET MEMORY Allocate space from a list of FSBs using the first fit-with-a-roving-pointer technique Input SIZE of area desired (must be two or more words) - SCB containing the FSB head node as defined in Figure 2-7 Output STATUS of the GET_MEMORY operation - LOCATION of the area, if allocation is successful FSB list structure is modified Assume Minimum allocation of two words in order that a returned area may be structured into an FSB (see Algorithm 2-2) Default STATUS to failure Initialize PREVIOUS pointer to ROVER from the head node Do Set CURRENT to link(PREVIOUS) If the current block is adequate, i.e., size(CURRENT) Then [ Allocate space from the current block ] SIZE or size(CURRENT) SIZE2 Set LOCATION to the last SIZE words of the block, i.e., to CURRENT size(CURRENT) - SIZE If all of the block is needed, i.e., LOCATION = CURRENT Then [ Delink the FSB from the list ] Else I Shorten the FSB ] EndIf Save a new roving-pointer value in the head node, i.e., set ROVER Change STATUS to success Advance PREVIOUS to CURRENT to continue searching Set link(PREVIOUS) to link(CURRENT) Decrement size(CURRENT) by SIZE to PREVIOUS Else EndIf Until an area is allocated or the list is exhausted, i.e., STATUS success or CURRENT- ROVER EndDo End GET_MEMORY Algorithm 2-1 First-Fit-with-a-Roving-Pointer Allocatiorn be validated. The normal action upon detection of incorrect conditions is to abort execution of the calling process Code to validate the input SIZE is essential. In addition, when the tests for adjacency with neighboring blocks are made, the FREE MEMORY routine should also test for overlapping blocks; that is, does the new area extend beyond the starting address of the successor or begin before the end of the predecessor

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

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions

Question

How does gneiss differ from granite?

Answered: 1 week ago