Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 ----------------------------------------------------------------------------

/*

def GetMemory(title, FSB1, FSB2, FSB3, Rover): word = raw_input("Enter the number of words you want to allocate: ") print ("GET_MEMORY IS RUNNING.......") print ("Initial FSB list") print(title, fsb1, fsb2, gsb3, rover) if int(word) <= fsb1[2]: # Size of area being returned fsb[2] = fsb[2]-int(word) fsb[1] = fsb[1]+int(word) rover = fsb2[1] print ("Allocation request for " + word + " words") print ("Allocation was successful") print ("Allocation was in location " + str(fsb1[1]-int(word))) print(title, fsb1, fsb2, fsb3, Rover) elif int(word) <= fab2[2]: fab2[2] = fsb2[2] - int(word) fsb2[1] = fab2[1] + int(word) rover = fsb3[1] print ("Allocation request for"+words+" words") print ("Allocation was successful") print ("Allocation was in location" +str(fsb2[1] - int(word))) print(title, fsb1, fsb2, fsb3, Rover) elif int(word) <= fab3[2]: fab2[2] = fsb3[3] - int(word) fsb2[1] = fab3[1] + int(word) rover = fsb3[1] print ("Allocation request for"+words+" words") print ("Allocation was successful") print ("Allocation was in location" +str(fsb2[1] - int(word))) print(title, fsb1, fsb2, fsb3, Rover) else: print("Allocation request for 150 words" +words+" words") print("Allocation was not successful") print(" . ") print(" . ") print(" . ") print("_____________________________________________________") print("_____________________________________________________") def FreeMemory(title, FSB1, FSB2, FSB3, Rover): word = raw_input("Enter the number of words you want to de-allocate: ") location = raw_input("Enter location") print ("FREE_MEMORY IS RUNNING.......") print ("Initial FSB list") print (title, fsb1, fsb2, gsb3, rover)

if int(location) == fab1(1): fab1(1) = int(location) fab1(2) = fab1(2)+int(word) print ("De-Allocation request of "+words+" words at location" +location) elif int(location) == fab1(1): fab2(1) = int(location) fab2(2) = fab1(2)+int(word) print ("De-Allocation request of "+ words+" words at location" +location) elif int(location) == fab3(1): fab2(1) = int(location) fab2(2) = fab1(2)+int(word) print ("De-Allocation request of "+ words+" words at location" +location) print (title, fsb1, fsb2, fsb3, rover) else: print("De-Allocation request for 150 words" +words+" words") print("De-Allocation was not successful") print(" . ") print(" . ") print(" . ") print("_____________________________________________________") print("_____________________________________________________") def Display(title, fsb1, fsb2, fsb3, Rover): print (" ", join(title)) print (fsb1) print (fsb2) print (fsb3) print ("Rover is " +str(rover)) print("______________________________________________________________") def main(): title = ['FSB#', 'Location', 'Size'] fsb1 = {1, 7, 4} fsb2 = {2, 14, 10} fsb3 = {3, 30, 20} Rover = 14 getMemory(title, fsb1, fsb2, fsb3, Rover) FreeMemory(title, fsb1, fsb2, fsb3, rover) main()

*/

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

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions