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 7.1: Phinding Palindromic Phrases Purpose: Learn string manipulation in the context of a simple program. For this problem, you will modify an existing program to be more flexible. Go to your copy of CheckPalindromicPhrase.ipynb from Lab Assignment 7. In the flavor of the work begun there, continue to modify the is_pal_phrase function to work for palindromic phrases and sentences by having it ignore spaces ignore case (upper versus lower) ignore common punctuation, that is the thirteen characters , ; : - ' " . ? ! ( ) [ ] For example, "a Toyota" and "Madam, I'm Adam." and "Was it a rat I saw?" should be identified as palindromes; ditto for "A man, a plan, a canal--Panama!" and "Madam (in Eden), I'm Adam." Comment every line you added, using the following format: # YOURINITIALS: your comment For example, here is a line from my function using one of the lines suggested in LA7: s = s.replace(" ","") # MSB: remove spaces from string A good plan of attack would be to add a…arrow_forward#17a Simple Statistics (not in textbook) Generate a STL array or vector of 1000 floating point numbers in the range 0 to 1. Compute the mean, median, and standard deviation of these. You may use function objects and lambda expressions, and the STL algorithms for_each, accumulate, and sort. You may not use any of the built-in looping constructs while, do-while or for. Also you may not create and use any ordinary c++ functions. Hint: The following code can be used to populate your random array named arr auto arr_store = [](float& v) { v = rand()/float(RAND_MAX); }; for_each(arr.begin(),arr.end(),arr_store); Warning, You may need to know some details about lambda expressions that are not covered in the textbook. These will be covered in the weekly lecture and in a sample program in Sakai resources. Note: The theoretical value of the standard deviation for large N is sqrt(1.0/12) which about 0.289. You should be getting a value fairly close to this.arrow_forward14.7 Practice using C++ hash templates C++ has two built in hash structures that will suite for most programming needs of hashes. The two types are unorderedmap and orderedmap. In this weeks program you are going to practice creating, inserting and iterating over the two types of maps. Your assignment is to create an unordered map and an ordered map, both with have key value pairs of type . You will read the key value pairs in from a dataFile using the file stream operator storing the first value (an integer into the integer key) and the second one into a string. You will then insert each pair into both the unordered and ordered maps. Lastly you will use an interator to iterate through the map printing them out. Your output should make it clear by label which list is the ordered map and which is the unordered map. The test provided is merely for your assistance - your program will be graded on it's content regardless of the results of book test. You will need the following references…arrow_forward
- 30.// programming Write a function void reverse(int a[ ], int size) to reverse the elements in array a, the second parameter size is the number of elements in array a. For example, if the initial values in array a is {5, 3, 2, 0}. After the invocation of function reverse(), the final array values should be {0, 2, 3, 5} In main() function, declares and initializes an integer array a with{5, 3, 2, 0}, call reverse() function, display all elements in final array a. Write the program on paper, take a picture, and upload it as an attachment. Or just type in the program in the answer area. m861144 m861144arrow_forwardIn c++ using the given codearrow_forwardPYTHON/ COMPUTATIONAL STOICHIOMETRY Please help me build the stochiometric matrix for the chemical reaction.kindly use the code provided to guide your solution. 1.7 A + 2.1 B + 1.5 C <=> 3 D + 3.8 E + 1.2 F Code Block to build stoichiometric matrix: import numpy as np # Initialize the stoichiometric matrix as zeros_mtrx = np.zeros((len(reactions), len(species))) for (i_row, r) in enumerate(reactions): left = r.split('<=>')[0].strip() right = r.split('<=>')[1].strip() left_terms = left.split('+') left_terms = [t.strip() for t in left_terms] # in-place clean up right_terms = right.split('+') right_terms = [t.strip() for t in right_terms] # in-place clean up for t in left_terms: # reactants tmp = t.split(' ') # split stoichiometric coeff and species name if len(tmp) == 2: # stoich coeff and species name coeff = float(tmp[0].strip()) species_member = tmp[1].strip() j_col…arrow_forward
- ""'Question"".arrow_forwardC++ Program (Markov matrix) An n by n matrix is called a positive Markov matrix if each element is positive and the sum of the elements in each column is 1. Write the following function to check whether a matrix is a Markov matrix. const int SIZE = 3; bool isMarkovMatrix(const double m[][SIZE]); Write a test program that prompts the user to enter a 3 by 3 matrix of double values and tests whether it is a Markov matrixarrow_forward8.arrow_forward
- """ This algorithm takes two compatible two dimensional matrix and return their product Space complexity: O(n^2) Possible edge case: the number of columns of multiplicand not consistent with the number of rows of multiplier, will raise exception """ def multiply(multiplicand: list, multiplier: list) -> list: """ :type A: List[List[int]] :type B: List[List[int]] :rtype: List[List[int]] """ multiplicand_row, multiplicand_col=len( multiplicand), len(multiplicand[0]) multiplier_row, multiplier_col=len.arrow_forwardIn python find_substring("It was the best of times, it was the worst of times", "i") [20, 26, 47] >>> find_substring('Episode III: Revenge of the Sith', "e ") [6, 19, 26] >>> find_substring("bobbobob", "bob") [0, 3, 5]arrow_forward;give fastarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education