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
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 9, Problem 9.15HW
Determine the block sizes and header values that would result from the following sequence of malloc requests. Assumptions: (1) The allocator maintains double-word alignment and uses an implicit free list with the block format from Figure 9.35. (2) Block sizes are rounded up to the nearest multiple of 8 bytes.
Request | Block size (decimal bytes) | Block header (hex) |
malloc(3) | ______ | ______ |
malloc(11) | ______ | ______ |
malloc(20) | ______ | ______ |
malloc(21) | ______ | ______ |
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
A page table may contain named entries (memory mapped files, such as code of an executable program) and anonymous mappings (page not backed by a file, such as the heap and stack of a program). Explain why (and how) a page fault handler has to handle these two cases differently when it needs to (1) evict a page from physical memory and (2) load a page into physical memory.
Consider the following code snippet in C:
char *base_url = malloc(11 * sizeof(char));
printf("Enter an 11 character URL: ");
scanf("%s", base_url);
char src[11];
char dst[11];
// copies base_url to src
strncpy(src, base_url, 11);
// copies src to dest
strcpy(dst, src);
printf("src: %s dst: %s\n", src, dst);
Identify at least one potential buffer overflow vulnerability and explain why/how it can be exploited (i.e., not just that it’s a buffer overflow, but where the problem will manifest itself).
Develop a C/C++ program that accepts the name of a memory trace file as a command line argument. Use the data to simulate a set associative cache using LRU replacement. Additional command line arguments will be needed to identify the details of the simulated cache. The arguments should appear in the following order:
the memory trace input file
X, where 2X == the number of direct-mapped sets
Y, where 2Y == the number of blocks per set
Z, where 2Z == the number of cached words per block
Your program (say it's a compiled C program) could be run like this:
./cache data.tra 3 2 4
This would simulate an 8 set associative LRU cache with 4 blocks per set, where each block caches 16 addresses. NOTE… the reason I've chosen to use exponents for arguments is to ensure we have powers of 2 for everything.
Trace File
The trace file is line based with each line containing a memory address requested, in hex. Please note this data is real, so the addresses are larger than 32-bits. In…
Chapter 9 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Ch. 9.2 - Prob. 9.1PPCh. 9.3 - Prob. 9.2PPCh. 9.6 - Prob. 9.3PPCh. 9.6 - Prob. 9.4PPCh. 9.8 - Practice Problem 9.5 (solution page 882) Write a C...Ch. 9.9 - Prob. 9.6PPCh. 9.9 - Prob. 9.7PPCh. 9.9 - Prob. 9.8PPCh. 9.9 - Prob. 9.9PPCh. 9.9 - Prob. 9.10PP
Ch. 9 - Prob. 9.11HWCh. 9 - Repeat Problem 9.11 for the following address....Ch. 9 - Repeat Problem 9.11 for the following address....Ch. 9 - Given an input file hello.txt that consists of the...Ch. 9 - Determine the block sizes and header values that...Ch. 9 - Prob. 9.16HWCh. 9 - Prob. 9.17HWCh. 9 - Prob. 9.18HWCh. 9 - Prob. 9.19HWCh. 9 - Write your own version of malloc and free, and...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Create an object of class Student. You will notice that this time you are prompted not only for a name of the i...
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Explain the difference between redundancy and diversity.
Software Engineering (10th Edition)
It is considered good programming practice to store the declaration for a class, its function definitions, and ...
Starting Out with C++: Early Objects
Bug Collector The Bug Collector Problem A bug collector collects bugs every day for five days. Write a program ...
Starting Out with Python (3rd Edition)
When two operators share an operand, the operator with the highest _____ executes first.
Starting Out With Visual Basic (7th Edition)
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- #include <stdio.h>#include <stdlib.h> #define SEQ_SIZE 50#define CACHE_SIZE 3 int page_reference_sequence[SEQ_SIZE]; int read_file(char *filename) // read in the page reference sequence from the file{ FILE *input; int i, n; if ((input = fopen(filename, "r")) == NULL) { printf("The input file does not exist.\n"); exit(1); } for (i = 0; i < SEQ_SIZE; i++) { if (fscanf(input, "%d", &page_reference_sequence[i]) == EOF) { // end of file n = i; // total number of page reference i = SEQ_SIZE; // stop reading from file } } fclose(input); printf("Input page reference sequence: "); for (i =0; i < n; i++) { printf("%d ", page_reference_sequence[i]); } printf("(total %d references)\n", n); return n; // return the total number of page reference} void FIFO(int n){ // write your own code for the FIFO policy // based on the input file content, print out a table similar to the Figure 22.2 int i;…arrow_forwardSelect problem below. Your post must include: The problem statement. A description of your solution highlighting the use of the split(), join(), lists and the different list operations involved in solving the problems. Include line numbers from your program. please make it simple and DONT use Java Create a program and reads a MAC address and determines whether it is syntactically correct or not. Assume the format of the MAC address is dd-dd-dd-dd-dd-dd where dd represents a 2-character hexadecimal number (each character is a digit or a letter between a and f). Use the `split function to access the values in the input MAC address.arrow_forwardWrite OPT Page Replacement Algorithm In C The user of your program should be able to: Specify a data file of page requests using a command line argument. Specify the size of the resident set (number of frames) using a command line argument. Specify the number of pages in the program using a command line argument. Simulate the running of each page replacement algorithm and determine the number of page faults.arrow_forward
- Allocation Methods. Explain how one can access ith block in contiguous allocation? Explain how one can access ith block in linked list allocation? Will you use linked allocation for an application with direct access? Explain. Compare FAT with I-node regarding a) RAM space requirements b) number of SEEKS required to read a Byte of information for each method. Assume a hard disk has D Blocks. how many entries will there be on FAT? Each block can hold B Bytes. It takes A Bytes to write one address. Or you can say the address pointer takes A Bytes. How many addresses can be contained in one block? How many blocks you will need to accommodate a File of F Bytes. Where F > B > A. Define and explain Bit vector and linked list approach to free-space management. Write their differences. Another set of questions I-node has file attributes. Users sometimes save same file in multiple names? In that case, do you need multiple I-nodes? yes or no- Explain your understanding. A file…arrow_forwardWrite a C code to perform vector arithmetic: Define 3 vectors A[100], B[100], C[100]. Get n from as a command line argument. Example if n=10, then (./vector 10), and create n processes. (n will be one of Divisors of 100). Get operation from user: add, sub. Each process will create a number of threads. Number of threads per process = 100/(10 number of processes). Perform the operation on a chunk of the vector, for example, if n = 10, each process will create (100/10*10=1) 1 thread to add\sub 10 elements. Use execl to run the add or sub programs Parent should print A.B.C in a file. (yourname.txt) For example, n=5, operation sub Partition work equally to each process: PO create (100/10*5=2) 2 threads → Thread00 will executes A[0:9] B[0:9]-C [0:9] = Thread01 will executes A[10:19] B[10:19]-C[10:19] = PI create (100/10*5=2) 2 threads → Thread 10 will executes A[20:29] = B[20:29]-C [20:29] Thread11 will executes A[30:39] B[30:39]- C[30:39] = and so on. no…arrow_forwardBelow is a list of 32-bit memory address references, given as memory addresses. 12, 720, 172, 8, 764, 352, 760, 56, 724, 176, 744You would like to access a cache with the given memory addresses. The size of cache is 23 = 8-blocks. Your task is to: (1) find out the binary address, (2) fill out the tag and index for each memory address and (3) indicate whether the access is hit or miss in the following table:arrow_forward
- 6. The figure below is a uni-directional list. Manila is the head of the list and the pointer contains addresses of data shown below. Batanes is the tail of the list and the pointer contains 0. Choose one correct way to insert Cebu placed at address 150 between Boracay and Davao. a) The pointer for Cebu to be set to 50 and that for Davao to be set to 150b) The pointer for Cebu to be set to 70 and that for Boracay to be set to 150c) The pointer for Cebu to be set to 90 and that for Davao to be set to 150d) The pointer for Cebu to be set to 150 and that for Boracay to be set to 90arrow_forwardProblem Given the target file f0 and candidate files f1-f20, there is an identical copy of f0 among the files f1-f20. Write a python program to perform the following tasks: · Read in each file and calculate the hex hash values by using SHA3 function with the length of 512 for all the given files f0, f1-f20. · Save the hex hash values of each file as a new line in a .txt file named hash.txt file. · Read hash values from hash.txt and compare them to find the identical copy of f0 among f1-f20. · Write the finding result (the matched file name) back to hash.txt Submission • Name your project fileHash.py and submit both fileHash.py and hash.txt on Blackboard. • The program should be properly documented. • The program should have user friendly Input/Output design • Duplicate work (or obviously similar one) will result in an F grade in the course. Grading 1. Include comments as specified in the course syllabus. (10%) 2. Source code and results. · Correctness (70%) · User-friendliness…arrow_forwardWrite a C program that implements the parent producer and child consumer algorithms. The parent process must copy an entire source file ("input.txt") to a destination file. In addition, the parent process must produce the file contents into shared memory as read from a source file (SRC_FILE) in chunks using the read() system call. The chunk size (CHUNK_SIZE) is the same for both read() and write(). It will be accepted as input by your program as a command-line argument.arrow_forward
- What is the working set page replacement algorithm? How does the working set algorithm work? Explain locality of reference with respect to memory references and how this applies to the working set page replacement algorithm.arrow_forwardinstruction is in the first picture please give me only implementation of int L1lookup(u_int32_t address) and int L2lookup(u_int32_t address) cacheSim.h #include<stdlib.h>#include<stdio.h>#define DRAM_SIZE 1048576typedef struct cb_struct {unsigned char data[16]; // One cache block is 16 bytes.u_int32_t tag;u_int32_t timeStamp; /// This is used to determine what to evict. You can update the timestamp using cycles.}cacheBlock;typedef struct access {int readWrite; // 0 for read, 1 for writeu_int32_t address;u_int32_t data; // If this is a read access, value here is 0}cacheAccess;// This is our dummy DRAM. You can initialize this in anyway you want to test.unsigned char * DRAM;cacheBlock L1_cache[2][2]; // Our 2-way, 64 byte cachecacheBlock L2_cache[4][4]; // Our 4-way, 256 byte cache// Trace points to a series of cache accesses.FILE *trace;long cycles;void init_DRAM();// This function print the content of the cache in the following format for an N-way cache with M Sets// Set 0…arrow_forwardAnswer the given question with a proper explanation and step-by-step solution. Consider the following source code, where k,l and m are constants declared with #define. The struct lnode is as defined as: struct lnode { char *str; // points to 32-character string struct lnode *next; // points to next node address struct lnode *prev; // points to prev node address }; You will need to determine the values for k, l and m, which are the dimensions of a 3-D array named A. struct lnode A[k][l][m]; int store_ele(int h, int i, int j, struct lnode dest) { A[h][i][j] = dest; return sizeof(A); } On compiling this program (with gcc -O2 -S -fno-asynchronous-unwind-tables) ,gcc generates the following assembly code for the store_ele function: store_ele: endbr64 movslq %edi, %rdi movslq %edx, %rdx movslq %esi, %rsi movdqu 8(%rsp), %xmm0 movq %rdi, %rax leaq (%rdx,%rdx,2), %rdx salq $6, %rax subq %rdi, %rax salq $4, %rax leaq (%rax,%rdx,8), %rax leaq (%rsi,%rsi,4), %rdx leaq (%rsi,%rdx,4), %rdx leaq…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Instruction Format (With reference to address); Author: ChiragBhalodia;https://www.youtube.com/watch?v=lNdy8HREvgo;License: Standard YouTube License, CC-BY