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...
Want to see the full answer?
Check out a sample textbook solutionChapter 9 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
- Problem 15 (#2.3.30).If f and f◦g are one-to-one, does it follow that g must be one-to-one? Justify your answer.arrow_forwardVII.Let A = {2, 4, 6, 8}, B = {6, 9}, C = {4, 8}. Answer each of the following questions. Justify your answers. 1. Is B ⊆B?arrow_forward(Practice) Run Program 7.10 to determine the average and standard deviation of the following list of 15 grades: 68, 72, 78, 69, 85, 98, 95, 75, 77, 82, 84, 91, 89, 65, and 74.arrow_forward
- 41. Which of the following statements is not true for the deadlock prevention and deadlock avoidance schemes? a. Deadlock avoidance is less restrictive than deadlock prevention. b. In deadlock prevention, the request for resources is always granted, if the resulting state is safe. c. It is the priority to have the knowledge of resource requirements for deadlock avoidance. d. In deadlock avoidance, the request for resources is always granted, if the resulting state is safe.arrow_forward5. (a) Write a function that solves the general linear least-squares problem. The inputs to your function should be a vector of a values, a vector of measured y values, and an anonymous function that calculates a single row of the Z matrix. Inside your function, use the inputted anonymous function to create Z row-by-row, then use Z to create the normal equations. Solve these normal equations to obtain the computed coefficients that define the best-fit of your model. Your function should output these calculated coefficients. Again, include an error check that makes sure the input vectors are the same size. You may not use any built-in MATLAB functions to solve the normal equation. You can use any functions you have developed solves Ax = b via LU-decomposition is one option. e.g. a function you have that (b) Test your function in (a) to fit the following model to the given dataset (see belo y = a + bx (c) Test your function in (a) to fit the following model to the given dataset…arrow_forwardI'm stuck on this problemarrow_forward
- Please provide solution for the following:arrow_forward2. (5.12 in 8e) answer each of the followig question. a) what does it mean to choose numbers "at random"? b) why is the rand function useful for simulating games of chance? c) why would you randomize a program by using srand? Under what circumstances is it desirable not to randomize? d) why is it often necessary to scale and/or shift the values produced by rand ?arrow_forwardPlease help me solve Part A of this problemarrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning