Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ You are to read in the input file and create a list to manage memory. You should have a single list that holds

In C++

You are to read in the input file and create a list to manage memory. You should have a single list that holds all the memory chunks (memory units). Each chunk should either contain the process name loaded into it or something to indicate it is a hole. Each chunk should also contain its starting address and size. When the simulation starts, the list should contain a single hole that fills the entire memory. When you perform a load, you will find the correct hole for the new process based on the algorithm indicated in the first line of the file. You need to be able to handle the firstFit, bestFit, and worstFit algorithms. In the example output below, these 3 algorithms all produce the exact same results until the point where H is loaded. At that point they differ. Make sure you try all three algorithms in your testing. When a process is unloaded nearby holes need to be combined to create a single large hole. That is, you should never have two holes next to each other on the hole list.

If a process is requesting more space that any hole, then your code should indicate that and not load the process. Normally, this is when a memory compaction algorithm would be run to combine all the free space together. We will not be implementing a compaction algorithm for this lab.

Your project must use the C++ list class

Memory_Chunk Class The constructor should have three parameters: the name of the process or a name to indicate a hole, the starting address of the memory chunk and the size of the chunk. You should create accessor and mutator methods as needed.

Memory_Manager Class The constructor should have one parameter, the name of the input file. The Memory_Manager Class should have one public member function named run. Your main method should: Check to see if the correct number of command line arguments is given. Create an object of type Memory_Manager. Call the Memory_Manager objects run method to start the simulation.

Sample Output for Example Input File hole:

start 0, size 50 load A 10 A: start 0, size 10 hole: start 10, size 40 load B 10 A: start 0, size 10 B: start 10, size 10 hole: start 20, size 30 load C 2 A: start 0, size 10 B: start 10, size 10 C: start 20, size 2 hole: start 22, size 28 load D 1 A: start 0, size 10 B: start 10, size 10 C: start 20, size 2 D: start 22, size 1 hole: start 23, size 27 load E 2 A: start 0, size 10 B: start 10, size 10 C: start 20, size 2 D: start 22, size 1 E: start 23, size 2 hole: start 25, size 25 load F 5 A: start 0, size 10 B: start 10, size 10 C: start 20, size 2 D: start 22, size 1 E: start 23, size 2 F: start 25, size 5 hole: start 30, size 20 4 load G 20 A: start 0, size 10 B: start 10, size 10 C: start 20, size 2 D: start 22, size 1 E: start 23, size 2 F: start 25, size 5 G: start 30, size 20 unload A hole: start 0, size 10 B: start 10, size 10 C: start 20, size 2 D: start 22, size 1 E: start 23, size 2 F: start 25, size 5 G: start 30, size 20 unload G hole: start 0, size 10 B: start 10, size 10 C: start 20, size 2 D: start 22, size 1 E: start 23, size 2 F: start 25, size 5 hole: start 30, size 20 unload C hole: start 0, size 10 B: start 10, size 10 hole: start 20, size 2 D: start 22, size 1 E: start 23, size 2 F: start 25, size 5 hole: start 30, size 20 unload E hole: start 0, size 10 B: start 10, size 10 hole: start 20, size 2 D: start 22, size 1 hole: start 23, size 2 F: start 25, size 5 hole: start 30, size 20

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

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students also viewed these Databases questions