Computer Systems: A Programmer's Perspective (3rd Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092997
Author: Bryant
Publisher: PEARSON
Expert Solution & Answer
Book Icon
Chapter 9.9, Problem 9.9PP

Explanation of Solution

Implementation of “place()” function:

In the “Section 9.9.12 (mm.c)”, add the below “place()” function to allocate the blocks. The function “place()” is as follows:

// Definition of place() function to allocate the requested block

static void place(void *bp, size_t asize)

{

// Call GET_SIZE() function to assign csize

size_t csize = GET_SIZE(HDRP(bp));

// Check the size

if ((csize - asize) >= (2 * DSIZE)) {

// Call PUT function with HDRP and PACK asize, 1

PUT(HDRP(bp), PACK(asize, 1));

// Call PUT function with FTRP and PACK asize, 1

PUT(FTRP(bp), PACK(asize, 1));

// Call NEXT_BLKP() function to assign bp

bp = NEXT_BLKP(bp);

// Call PUT function with HDRP and computed PACK size, 0

PUT(HDRP(bp), PACK(csize - asize, 0));

// Call PUT function with FTRP and computed PACK size, 0

PUT(FTRP(bp), PACK(csize - asize, 0));

}

// Otherwise

else {

// Call PUT function with HDRP and PACK csize, 1

PUT(HDRP(bp), PACK(csize, 1));

// Call PUT function with FTRP and PACK csize, 1

PUT(FTRP(bp), PACK(csize, 1));

}

}

Explanation:

The “place()” function is to allocate the requested block.

  • A pointer “bp” represents which place the block is allocated.
  • Call “GET_SIZE()” function to assign “csize”.
  • “if” statement to check the size to fit the block.
    • The function “HDRP()” and “FTRP()” represents the place of the pointer.
    • Compute the size by calling “PACK()” function.
    • Place the block if the condition is satisfied using “PUT()” function.

Filename: main.c

// Include libraries

#include <stdio.h>

#include <stdlib.h>

#include <assert.h>

// Include required header files

#include "csapp.h"

#include "memlib.h"

#include "mm.h"

#include "memlib.c"

#include "mm...

Blurred answer
Students have asked these similar questions
3. The diagram below shows the main land routes for vehicular traffic between points A and G in a city. The figures in the arcs represent the cost of traveling between each pair of nodes.   a) Manually apply Dijkstra's algorithm to find the cheapest route between A and G (visited nodes and total distance). b) Formulate a linear programming problem in extended form, to determine the shortest route to travel from A to G. Do not use subscripts, name 14 variables, for example XFE would be the variable that indicates that the arc from F to E is used. c) If there is a fixed cost for visiting each node, modify the formulation of the problem to include said fixed cost in the objective function, and the variables and restrictions that are required.     NODE A B C D E F G FIXED COST 25 18 32 20 28 18 34
Problem 3 (#2.1.32).Explain why (A×B)×(C×D)and A×(B×C)×D are not the same
4.1.1 Complete solution and answer only no need explanation Given three data points (1,6), (3,28), and (10, 231), What is the value of y at x = 2 if the function y = 2x2 + 3x + 1 passes through the three data points.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning