This problem will have you analyze the allocation pattern of a memory allocator to assess how different allocation policies affect where data is allocated and the corresponding fragmentation. Assume that memory is word addressed and each word in the diagram below holds a single datum. To simplify the problem, assume there are not "header" and "footer" words and only allocate the words indicated in the call to malloc. The heap is shown below and it is initially empty. Memory address: 1 2 3 4 5 6 7 8 9 10 11 Heap: Now we have the scenario of these instructions: 1: p1 = malloc(3); 2: p2 = malloc(3); 3: p3 = malloc(2); 4: p4 = malloc(3); 5: free(P1); 6: free(p3); 7: p5 = malloc(2); 8: free(p2); 9: free(p4); 10: p6 = malloc(6); 11:free(p5); 12: p7 = malloc(6); If the heap is using the first fit policy in allocating blocks, what is the value of p5 after instruction 7th execution? If the heap is using the best fit policy in allocating blocks, what is the value of p5 after instruction 7th execution? If the heap is using the best fit policy in allocating blocks, what is the value of p6 after instruction 10th execution? If the heap is using the best fit policy in allocating blocks, what is the value of p7 after instruction 12th execution?
Added by Daniel A.
Close
Step 1
First Fit Policy: 1: p1 = malloc(3) -> p1 points to 1 2: p2 = malloc(3) -> p2 points to 4 3: p3 = malloc(2) -> p3 points to 7 4: p4 = malloc(3) -> p4 points to 9 5: free(p1) -> frees memory at 1 6: free(p3) -> frees memory at 7 7: p5 = malloc(2) -> p5 points to 1 Show more…
Show all steps
Your feedback will help us improve your experience
Anand Jangid and 84 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Consider a memory of size 8KB (8192 bytes) that allows dynamic, variable sized partitioning among processes and uses a linked list to keep track of free spaces (hereafter referred to as the free list) in the memory at any given time. Assume that there are 6 processes and assume that their memory size requirements (in bytes) are as given below: P1: 500, P2: 600, P3: 1300, P4: 2000, P5: 100, P6: 200 Assume that the initial state of the free list is as shown below (BA is the base address and Sz is the size of each free space): BA: 0; Sz: 1100 → BA: 1200; Sz: 600 → BA: 2000; Sz: 1800 → BA: 6000; Sz 400 For these next questions assume the free list is in its initial state. Assume that the worst fit policy is used for partition placement. Identify the base address of the region to which each of the following processes will be allocated, assuming that they are allocated in the order specified and show the updated free liststate after each allocation. Note: If a partition cannot be allocated due to the state of the free list, simply type in the words cannot be accommodated as your answer. Question 1: If P2 is allocated, what is the BA? _______ Question 2: The updated free list is: BA: _________ ; Sz: __________→ BA: __________ ; Sz: ___________→ BA: __________ ; Sz: __________ → BA: _________ ; Sz ___________
Akash M.
4. There is a memory system where paging is being used. Assume the physical memory address length/space is 42 bits. In addition, the frame size is 4 bytes. If the page table size is 16 MB, then find out the logical address length/space (represented in the number of bits). (Show the procedure). 5. Consider a three-level Page Table Scheme, where the logical address space is 64 bits. i. If the Page size is 4 KB, then find out the Offset size? ii. If 2nd outer page size is 32 and 1st outer page is 12, then find out the inner page size? iii. Finally, show the complete figure/diagram of the three-level page scheme (based on i and ii).
Virtual Memory The following problem concerns the way virtual addresses are translated into physical addresses. The memory is byte addressable. The page size is 64 bytes. The TLB is 4-way set associative with a total of 16 entries. The cache is 2-way set associative, with a line size of 4 bytes and a total of 16 lines. Memory accesses are to 1-byte words (not 4-byte words). Virtual addresses are 15 bits wide, while physical addresses are 13 bits wide. Part 1 The box below shows the format of a virtual address. Indicate (by labeling the diagram) the fields (if they exist) that would be used to determine the following: (If a field doesn't exist, don't draw it on the diagram.) VPO - The virtual page offset VPN - The virtual page number TLBI - The TLB index TLBT - The TLB tag (a) 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Remember to double-check your answer. The box below shows the format of a physical address. Indicate (by labeling the diagram) the fields that would be used to determine the following: PPO - The physical page offset PPN - The physical page number CO - The block offset within the cache line CI - The cache index CT - The cache tag (b) 12 11 10 9 8 7 6 5 4 3 2 1 0 Remember to double-check your answer.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD