Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

First fit, best fit, worst fit, or none of the above? I need help on figuring out whether heap allocator allocates the chnnk using first

First fit, best fit, worst fit, or none of the above? I need help on figuring out whether heap allocator allocates the chnnk using first fit, best fit, worst fit, or none of the above. In the beginning best fit but it looks none of the above too. Here's the questions. sizes between addresses = 1024, 64, 1024, 512, 1024, 128, 1024, 64, 1024 

Question #1

If invoking the program as

memory 480,0,0,0 

produced this output:

0 | 1024 | 1088 | 2112 | 2624 | 3648 | 3776 | 4800 | 4864 | -------------- The 480-byte chunk was allocated at address 2144 

would you conclude that the heap allocator allocates new chunks of RAM at the beginning (i.e., lower addresses) or at the end (i.e., higher addresses) of holes in memory? Why? To explain why just use a contraposition argument (e.g., if the heap allocator did X then Y would have happened, but instead Z happened).

Whatever the heap allocator does, this is what we assume it does for all subsequent questions.

Question #2

If invoking the program as

./memory 100,200,100,80 

produces this output:

0 | 1024 | 1088 | 2112 | 2624 | 3648 | 3776 | 4800 | 4864 | -------------- The 100-byte chunk was allocated at address 2524 The 200-byte chunk was allocated at address 2324 The 100-byte chunk was allocated at address 2224 The 80-byte chunk was allocated at address 3696 

would you say that the heap allocator uses

first fit

best fit

worst fit

none of the above?

Question #3

If invoking the program as

./memory 40, 400, 80, 60 

produces this output:

0 | 1024 | 1088 | 2112 | 2624 | 3648 | 3776 | 4800 | 4864 | -------------- The 40-byte chunk was allocated at address 3736 The 400-byte chunk was allocated at address 2224 The 80-byte chunk was allocated at address 2144 The 60-byte chunk was allocated at address 4804 

would you say that the heap allocator uses

first fit

best fit

worst fit

none of the above?

Question #4

After looking up some documentation, you find out that the heap allocator uses worst fit! What would the output of the memory program be when invoked as follows:

./memory 400, 100, 10, 10 

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

Visual Basic6 Database Programming

Authors: John W. Fronckowiak, David J. Helda

1st Edition

0764532545, 978-0764532542

More Books

Students also viewed these Databases questions

Question

3. A scholarship-holders base.

Answered: 1 week ago