Computer Systems: A Programmer's Perspective (3rd Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
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
(In java please) ( NO TOY CLASS PLEASE READ INSTRUCTION OR DOWN VOTE PLEASE LOOK AT TWO IMAGES BELOW FIRST ONE IS CURRENCY CLASS NEED THE SECOND IS INSTRUCTIONS ON HOW TO MAKE TEST CLASS. PLEASE NO TOY CLASS OR DOWN VOTE USE CURRENCY CLASS INSTEAD AND UPDATE IT) THIS A LinkNode structure or class which will have two attributes - a data attribute, and a pointer attribute to the next node. The data attribute of the LinkNode should be a reference/pointer of the Currency class of Lab 2. Do not make it an inner class or member structure to the SinglyLinkedList class of #2 below. A SinglyLinkedList class which will be composed of three attributes - a count attribute, a LinkNode pointer/reference attribute named as and pointing to the start of the list and a LinkNode pointer/reference attribute named as and pointing to the end of the list. Since this is a class, make sure all these attributes are private. The class and attribute names for the node and linked list are the words in bold in #1…
Problem 1. (RSA Library) Implement a library called rea.py that provides functions needed for developing the RSA cryp- tosystem. The library must support the following API: rsa generates and returns the public/private keys as a tuple (n, e, d), picking prime numbers p and q needed to generate the keys from the interval [1o, hi) encrypts x (int) using the public key (a, e) and returns the encrypted value decrypts y (int) using the private key (a, d) and returns the decrypted value returns the least number of bits needed to represent a returns the binary representation of a expressed in decimal, having the given width and padded with leading zeros returns the decimal representation of a expressed in binary keygen (lo, hi) евcrypt (x, a, е) decrypt (y, n, d) bitLength (n) dec2bin (n, width) bin2dec (n) > "/vorkspace/project4 $ python3 rsa.py S encrypt (S)- 1743 decrypt (1743) - s bitlength (83) - 7 dec2bin (83) - 1010011 bin2dec (1010011) - 83 Directions: 4 / 7 Project 4 (RSA…
(QI. 5.) Write a C++ class member function to print alternate nodes of the given Linked List, first from head to end, and then from end to head. If Linked List has even number of nodes, then function skips the node. (Example: Input: 1->2->3->4->5, output: 13553 1).
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education