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
EBK COMPUTER SYSTEMS
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY