Assume we have a free space management system as described in the book, for example one used to provide us with virtual addresses on the heap (with physical addresses handled by a much simpler system since we assume paging). Assume the system uses the following very simple rules; A memory request traverses the free list, and finds the first block large enough to handle the request (i.e., the first fit algorithm from the book). It then: Splits the block into 2 pieces: The first piece will be the requested size + 1k (for a header). The second will be the remaining The first piece will be returned to the caller, but the address returned will be the address of the memory for the user, that is the header + 1k The second will be put back into the linked list If there's insufficient contiguous memory, the allocation will fail (return 0) Free memory is stored as a linked list in address order Assume we start with a single contiguous block of FREE memory of size 64k starting at location 32k in memory. Consider the following sequence of mallocs and frees: 1 x = malloc(7168); /* 7k */ 2 y = malloc(5120); /* 5k */ 3 z = malloc(11264); /*11k */ 4 free(x); 5 x = malloc(8192); /* 8k */  6 free(y); 7 y = malloc(12288); /* 12k */  8 free(z); 9 z  = malloc(38912); /* 38k */ Please fill in the requested addresses. Note that since everything is in k, you may use raw numbers (e.g., 1024) or the equivalent k (e.g., 1k). The address returned to the caller for x in line 1? The address returned to the program for y in line 2? The address returned to the program for z in line 3? The address reclaimed by the OS in line 4 (hint: This may not be the same as the address of x)? The address returned to the program for x in line 5? The address reclaimed by the OS in line 6 (hint: This may not be the same as the address of y)? The address returned to the program for y in line 7? The address reclaimed by the OS in line 8 (hint: This may not be the same as the address of z)? The address returned to the caller for z in line 9?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Topic Video
Question

Assume we have a free space management system as described in the book, for example one used to provide us with virtual addresses on the heap (with physical addresses handled by a much simpler system since we assume paging). Assume the system uses the following very simple rules;

  • A memory request traverses the free list, and finds the first block large enough to handle the request (i.e., the first fit algorithm from the book). It then:
    • Splits the block into 2 pieces: The first piece will be the requested size + 1k (for a header). The second will be the remaining
    • The first piece will be returned to the caller, but the address returned will be the address of the memory for the user, that is the header + 1k
    • The second will be put back into the linked list
  • If there's insufficient contiguous memory, the allocation will fail (return 0)
  • Free memory is stored as a linked list in address order

Assume we start with a single contiguous block of FREE memory of size 64k starting at location 32k in memory. Consider the following sequence of mallocs and frees:

1 x = malloc(7168); /* 7k */
2 y = malloc(5120); /* 5k */
3 z = malloc(11264); /*11k */
4 free(x);
5 x = malloc(8192); /* 8k */ 
6 free(y);
7

y = malloc(12288); /* 12k */ 

8 free(z);
9 z  = malloc(38912); /* 38k */

Please fill in the requested addresses. Note that since everything is in k, you may use raw numbers (e.g., 1024) or the equivalent k (e.g., 1k).

The address returned to the caller for x in line 1?

The address returned to the program for y in line 2?

The address returned to the program for z in line 3?

The address reclaimed by the OS in line 4 (hint: This may not be the same as the address of x)?

The address returned to the program for x in line 5?

The address reclaimed by the OS in line 6 (hint: This may not be the same as the address of y)?

The address returned to the program for y in line 7?

The address reclaimed by the OS in line 8 (hint: This may not be the same as the address of z)?

The address returned to the caller for z in line 9?

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

this is what my professor said:

1. Memory starts at 32k, but we always have a leading 1k header, so 33k will be returned. Your reclaim (in 4) however, will reclaim the header too, so that will be 32k. You missed this. In step ~5 however, you state that there's room for 8k at 32, but you actually need 9k (8k+1) and don't have it.

 

Can someone please fix this and give me all the answers again?

Solution
Bartleby Expert
SEE SOLUTION
Follow-up Question

In the previous answers:

Isn't 1 is supposed to be subtracted from the 64 as well?

  1. Malloc for x:

    • Requested size: 10k
    • Address returned to the caller: 32k + 1k = 33k (since x will be placed after the header of 1k)
    • Address returned to the program: 33k
    • Remaining free memory: 54k (64k - 10k) (here)
    • Address of the remaining free memory: 43k


and
Here, the requested size is 20, why is 10 subtracted?

  1. Malloc for y (again):

    • Requested size: 20k
    • Address returned to the caller: 44k (previous address)
    • Address returned to the program: 44k (previous address)
    • Remaining free memory: 54k (64k - 10k) (here)
    • Address of the remaining free memory: 64k
Solution
Bartleby Expert
SEE SOLUTION
Follow-up Question

The address returned to the caller of z on line 9 is 33792 (beginning of free memory block) + 1k (header) = 34816.

this doesn't follow the line 5 and line 7. 
Could you please explain why 33792 returned to in line 9 and 32k in line 5 and 7?

thank you

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education