This preview shows page 1. Sign up to view the full content.
Unformatted text preview: (HDRP(bp), PACK(csize, 1)); PUT(FTRP(bp), PACK(csize, 1)); } } code/vm/malloc.c 734 Problem 10.10 Solution: [Pg. 545] APPENDIX B. SOLUTIONS TO PRACTICE PROBLEMS Here is one pattern that will cause external fragmentation: The application makes numerous allocation and free requests to the ﬁrst size class, followed by numerous allocation and free requests to the second size class, followed by numerous allocation and free requests to the third size class, and so on. For each size class, the allocator creates a lot of memory that is never reclaimed because the allocator doesn’t coalesce, and because the application never requests blocks from that size class again. B.11 Concurrent Programming with Threads
Problem 11.1 Solution: [Pg. 569] This is your ﬁrst exposure to the many synchronization problems that can arise in threaded programs. A. The problem is that the main thread calls exit without waiting for the peer thread to terminate. The exit call terminates the entire process, including any threads that happen to be running. So the peer thread is being killed before it has a chance to print its output string. B. We can ﬁx the bug by replacing the exit function with either pthread exit, which waits for outstanding threads to terminate before it terminates the process, or pthread join which explicitly reaps the peer thread. Problem 11.2 Solution: [Pg. 572] The main idea here is that stack variables are private while global and static variables are shared. Static variables...
View Full Document
This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.
- Spring '10
- The American