Question

In: Computer Science

A one Megabytes block of memory is allocated using the buddy system. Show the results of...

A one Megabytes block of memory is allocated using the buddy system. Show the results of the following sequence of requests and returns in a figure that is similar to Figure 7.6: Request A: 200 Kilobytes;

Request B: 80 Kilobytes;

Request C: 380 Kilobytes;

Return A;

Request D: 120 Kilobytes;

Return B;

Return D;

Return C.

Also, find the internal fragmentation at each stage of allocation/de-allocation.

Solutions

Expert Solution

  • Request A: 200 kilobytes
    No such block found, so we traverse up and split the 0-1024 block into 0-511, 512-1024; we add 512-1024 to list tracking 512 Kilobyte blocks and pass 0-511 downwards; again it is split into 0-255 and 255-512; since we have found the required block size, we add 512-1024 to list tracking
    We have 56 kb internal fragmentation here.
  • Request B: 80 kilobytes
    No such block found, so we traverse up and split the 256-512 block into 256-383, 384-512; since we have found the required block size, we add 384-512 to list tracking
    We have 48kb internal fragmentation here.
  • Request C: 380 kilobytes
    we have found the required block size 512-1024
    We have 132kb internal fragmentation here.
  • Deallocation Request A: 200 kilobytes
    Deallocation will be done,no coalesscing possible  and 0-255 block is free.
  • Request D: 120 kilobytes
    No such block found, so we traverse up and split the 0-255 block into 0-127, 128-255; we have found the required block size. we have 8kb internal fragmentation here.
  • Deallocation Request B: 80 kilobytes
    Deallocation will be done, no coalesscing possible  and 256-383 block is free.
  • Deallocation Request D: 120 kilobytes
    Deallocation will be done, coalesscing of the blocks 0-127,128-255 ,256-512 will also be done and 0-127 block is free.
  • Deallocation Request C: 380 kilobytes
    Deallocation will be done,coalesscing of the blocks 0-511, 512-1024 will also be done and 512-1024 block is free.

Related Solutions

malloc() searches the recently de-allocated memory objects to satisfy incoming memory allocation request. Explain the rationale...
malloc() searches the recently de-allocated memory objects to satisfy incoming memory allocation request. Explain the rationale of this design.
Implement a Linux Block Driver which simulates a block device with a region of memory init,...
Implement a Linux Block Driver which simulates a block device with a region of memory init, exit, and IO functionalities must be included. Please use either C or C++ Programming for this Thank You!
ISP have been allocated the address block 200.23.16.0/20 ISP, wants to divide its address block into...
ISP have been allocated the address block 200.23.16.0/20 ISP, wants to divide its address block into four equal sized address blocks and give one to each of four organizations. Write the address range and also subnet mask for each organization
1) Which one of the following would most likely be allocated to products using ABC by...
1) Which one of the following would most likely be allocated to products using ABC by McDonald's? A) Cost of plastic gloves worn by the burger cooks B) Cost of employees who chop lettuce C) Cost of tomatoes added to burgers D) Cost of cups for soft drinks 2) Fixed costs..... A) increase per unit as total production decreases B) increase in total as total production increases C) decrease in total as total production decreases D) decrease per unit as...
We decide to speed up the virtual memory system of question 1 by using a translation...
We decide to speed up the virtual memory system of question 1 by using a translation lookaside buffer (TLB). Suppose your memory system has the characteristics shown in the following table. The TLB and cache miss rates indicate how often the requested entry is not found. The main memory miss rate indicates how often page faults occur.                                                                            Memory Characteristics Memory Unit Access Time (Cycles) Miss Rate TLB 1 0.05% Cache 1 2% Main memory 100 0.0003% Hard drive...
Memory was allocated initially for 5 elements, later on two more elements added to list. How...
Memory was allocated initially for 5 elements, later on two more elements added to list. How can space be managed in such case. Implement the scenario in C. IN C PROGRAMING
A block of memory contains 40 random words of data. Assume that the values are in...
A block of memory contains 40 random words of data. Assume that the values are in two’s complement representations and are stored in the Read/Write memory area. You need to provide the 40 random words and to include them in an initialization file: assign.ini. Write a program using the ARM assembly programming language to do the following: a) You are required to reverse the word order in a block of 40 random words (Hint: the last word stored in the...
Using Activity based costing, why are indirect costs allocated while direct costs are not allocated?
Using Activity based costing, why are indirect costs allocated while direct costs are not allocated?
Prime Sum C program !! Dynamically allocated memory Let P(n) denote the sum of the first...
Prime Sum C program !! Dynamically allocated memory Let P(n) denote the sum of the first n prime numbers. For example, P(1) = 2 and P(3) = 10, since the first three prime numbers are 2, 3 and 5, respectively. Write a program to determine the value of the function P(n) for different values of n. The first few prime sums are 2, 5, 10, 17, 28, 41, 58 and 77. Input The first line of the input file contains...
Consider a block-spring system as shown in the figure. The block is attached to the spring,...
Consider a block-spring system as shown in the figure. The block is attached to the spring, which is attached to the inside wall of the box. The mass of the block is 0.2kg. Suppose you pull the block 10cm to the right and release it. The angular frequency for it to oscillate is 30 rad/s. Neglect friction between the block and the bottom of the box. (a)What is the spring constant of the spring? (b)What will be the amplitude of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT