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
Question
Chapter 9.9, Problem 9.10PP
Program Plan Intro
Simple Segregated Storage:
Simple Segregated Storage is the fastest and simplest
- It works by separating a blocks of memory into fixed size chunks.
- The free list holds same size blocks for each size class, respectively the size of the largest item of the size class.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
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…
We can solve memory leaks with
using a tombstone or lock and keys approach to the dangling pointer problem
using a tombstone or mark-sweep approach to the dangling pointer problem
some form of garbage collection such as mark-sweep or reference counters
some form of garbage collection such as tombstones or lock-and-keys
3 Malloc—Dynamic Memory Allocation
1. Give an example where a malloc()-like allocator would fail due to external fragmentation.
2. Give an example where returning a block to the allocator results in reducing the number of free blocks. Assume an implicit free list is used.
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...
Knowledge Booster
Similar questions
- Programming Language Pragmatics, 4th Editionarrow_forwardQ7. ] Given the following ARM64 assembly code for a function, add comments to each line, use its stack frame with corresponding variables, and trace the code execution to figure out what it does. Notice that local variables are stored in the function's stack frame. Hint: this is a void function that takes two input parameters. tunct: sub sp. sp, #32 str x0, (sp, 8] Address Contents x1, [sp) Idr x0, Isp, 81 str SP Sp + 4 Sp +8 Sp + 12 Sp + 16 Sp + 20 Sp + 24 Sp + 28 Idr wo, [x0] str wo, [sp, 28] Idr x0, [sp) Idr w1, [x0] Idr x0, [sp, 8] w1, [x0] Idr x0, Isp) str Idr w1, [sp, 28] str w1, [x0] DOR add Sp. sp, 32 retarrow_forwardQuestion 4: Question 3: Consider the following code which computes the inner product of 2 vectors: prod := 0; i = 1; repeat { prod := prod + a[i] *b[i] i=i+1; until i > 20 } a. Convert the given code into Intermediate Representation - Three Address Codearrow_forward
- 3. Which stack protection techniques are vulnerable to return-orlented programming? a. Stack Canaries b. Address space layout randomization c. Limiting Executable Code Regions 4. In malloclab, several students implemented an optimization where small blocks would be allocated at the beglinning of a free block, and large blocks would be allocated at the end of a free block. In what way was this useful on some traces? a. It increases the memory utilization due to less Internal fragmentation. b. It increagos tho momory utlization duo to moro coaloscing opportunities. c. Itincreases the throughput due to smaller free lists. d. It increases the throughput due to better temporal locality in caches. 5. After a forki), to access which datastnuctures, should the resulting two processes synchronize? а. Неар b. Stack c. Registers d. Globals e. Program Codearrow_forward3. In the StackGuard approach to solving the buffer overflow problem, the compiler inserts a canary value on the memory location before the retum address in the stack. The canary value is randomly generated. When there is a return from the function call, the compiler checks if the canary value has been overwritten or not. Do you think this approach would work? Why or why not?arrow_forwardPlease solve and show all work. Use a generic swap function to swap two fraction objects frac1 and frac 2. Write the code in C with input of num and deno (using a readFunction) and output the swap values (using a printFunction) struct fraction { int num; int deno; };arrow_forward
- Security: 1. Buffer overflow A C code example for Buffer Overflow is below: #include #define BUFFER SIZE 256 int main(int argc, char *argv[]) { char buffer[BUFFER SIZE]; if (argc <2) return -1; else { } strcpy(buffer,argv[1]); return 0; } (a) Explain the C code here on what it is doing. (b) Explain why buffer overflow may happen (c) Explain how you can modify the code to avoid buffer overflow.arrow_forwardPaging is a memory management scheme that eliminates the need for contiguous allocation of physical memory. This scheme permits the physical address space of a process to be non – contiguous. Given below is one of the page replacement algorithm program, you are to first identify which algorithm (FIFO, Optimal Page Replacement, Least frequently used) is implemented in given c-code. Please consider following reference string for this page replacement algorithm(1,2,3 5,1,3,4,5,6,1,5,3,2) with 4 page/frame size. There are some errors in this program, you have to correct it first, and then explain compiled output with each miss or hit condition. Note: Show complete procedure with detail steps/screenshots with your arid number (19-ARID-1041). #include <stdio.h> void main() { intpos,c,m,maxi,i,k,nf,count,j=0,pf=0,np=0; printf("enter no. of pages"); scanf("%d",&np); int s[np]; printf("Enter pages sequence :\n");…arrow_forwardPaging is a memory management scheme that eliminates the need for contiguous allocation of physical memory. This scheme permits the physical address space of a process to be non – contiguous. Given below is one of the page replacement algorithm program, you are to first identify which algorithm (FIFO, Optimal Page Replacement, Least frequently used) is implemented in given c-code. Please consider following reference string for this page replacement algorithm (1,2,3 5,1,3,4,5,6,1,5,3,2) with 4 page/frame size. There are some errors in this program, you have to correct it first, and then explain compiled output with each miss or hit condition. Note: Show complete procedure with detail steps/screenshots with your arid number. #include <stdio.h> void main() { int pos,c,m,maxi,i,k,nf,count,j=0,pf=0,np=0; printf("enter no. of pages"); scanf("%d",&np); int s[np]; printf("Enter pages sequence :\n");…arrow_forward
- Paging is a memory management scheme that eliminates the need for contiguous allocation of physical memory. This scheme permits the physical address space of a process to be non – contiguous. Given below is one of the page replacement algorithm program, you are to first identify which algorithm (FIFO, Optimal Page Replacement, Least frequently used) is implemented in given c-code. Please consider following reference string for this page replacement algorithm (1,2,3 5,1,3,4,5,6,1,5,3,2) with 4 page/frame size. There are some errors in this program, you have to correct it first, and then explain compiled output with each miss or hit condition. #include <stdio.h> void main() { int pos,c,m,maxi,i,k,nf,count,j=0,pf=0,np=0; printf("enter no. of pages"); scanf("%d",&np); int s[np]; printf("Enter pages sequence :\n"); for(i=0;i<np;i++) scanf("%d",&s[i]); printf("enter the no. of…arrow_forwardQuestion 1 (a) What is fragmentation? Briefly explain what it is and how we address it. (b) Explain the role of the stack and the heap, using an example of call- ing a function that then allocates memory for 100 integers to a local pointer variable. You may use a diagram if you wish.arrow_forward(i) Suppose an initially empty stack S has executed a total of 30 push operations,20 top operations, and 18 pop operations, 8 of which raised Empty errors that were caught and ignored. What is the maximum and current size of S? Clearly write how you calculated the current size of S based on the stack operations. How many overflow errors would have occurred during the push operations?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning