Andrew login ID Full Name Section 15 213 18 243 Spring 2011 Exam 2 Thursday April 21 2011 v2 Instructions Make sure that your exam is not missing any sheets then write your Andrew login ID full name and section on the front This exam is closed book and closed notes A notes sheet is attached to the back Write your answers in the space provided below the problem If you make a mess clearly indicate your final answer The exam has a maximum score of 100 points The problems are of varying difficulty The point value of each problem is indicated Good luck 1 12 2 15 3 20 4 18 5 10 6 15 7 10 TOTAL 100 Page 1 of 13 Problem 1 12 points Multiple choice Write the correct answer for each question in the following table 1 2 3 4 5 6 7 8 9 10 11 12 13 X 14 X 15 X 16 X 17 X 18 X 19 X 20 X 1 What kind of process can be reaped a Exited b Running c Stopped d Both a and c 2 Which of the following functions will always return exactly once a exec b exit c fork d None of the above 3 Given an arbitrary malloc implementation that does not coalesce and a second implementation that is identical except it does coalesce which of the following is true about their utilization scores on an arbitrary trace You may assume the first implementation stores enough information to make coalescing possible so the only difference is that the second implementation actually performs the coalescing a The coalescing malloc will definitely get a better utilization score b The coalescing malloc might get a better utilization score and might get the same utilization score but it cannot get a worse utilization score c The coalescing malloc might get a better utilization score might get the same utilization score and might get a worse utilization score d The coalescing malloc will definitely get a worse utilization score Page 2 of 13 4 Which of the following is a reason next fit might perform better than first fit a If a large number of small blocks are stored at the beginning of the free list next fit avoids walking through those small blocks upon every allocation b First fit requires a traversal of the entire free list but next fit does not c First first requires that both allocated and unallocated blocks be examined and next fit examines only free blocks d Next fit is an approximation of best fit so it reduces internal fragmentation compared to first fit 5 How much virtual memory can be addressed by a 32 bit system a b c d 2GB 4GB 8GB 240TB 6 Which of the following is a reason why a virtual memory translation would fault a b c d Page is not present Page is read only Page is empty All of the above 7 How many bits are needed for the Virtual Page Offset if page size is 5000 bytes a b c d 10 11 12 13 8 Which of the following is preserved across exec a b c d Signal handlers Blocked signals a and b Neither 9 In what section of an ELF binary are initialized variables located a b c d symtab data bss text Page 3 of 13 10 What does the call dup2 oldfd newfd do a newfd and oldfd now both refer to oldfd s entry in the open file table b A copy of oldfd s open file table entry is made and newfd points to the copy c A copy of the file oldfd is pointing to is made on the filesystem The file is then opened and newfd points to that open file entry d The numerical value in oldfd is copied into newfd No changes are made in the system 11 Which of the following are shared between a parent and child process immediately following a fork a Writeable physical memory b File descriptor tables c Instruction pointer d Open file structs 12 Which signals cannot be handled by the process a SIGTSTP b SIGKILL c SIGTERM d All of the Above Page 4 of 13 Problem 2 15 points Process control Consider the following code sample You may assume that no call to fork exec wait or printf will ever fail and that stdout is immediately flushed following every call to printf int global x 0 int main int argc char argv global x 17 Assume fork never fails if fork global x printf Child d n global x else wait NULL global x printf Parent d n global x return 0 A What is printed by this program B How might the output change if we removed the call to wait Note Keep your answer short you will be penalized for excessively long answers Page 5 of 13 Now consider the following two code samples Again you may assume that none of the previously mentioned function calls can fail You should also note that the source for my child follows the source for the invoked program int global x 0 int main int argc char argv global x 17 Assume fork never fails if fork global x Assume exec never fails execl my child my child NULL printf Child finished n else wait NULL global x printf Parent d n global x return 0 Code Listing for my child int global x int main int argc char argv printf Child d n global x return 0 C Is the output for this program the same as for the previous Why or why not Note Again your answer to this question should be short Page 6 of 13 Problem 3 20 points Dynamic memory allocation In this question we will consider the utilization score of various malloc implementations on the following code define N 32 void pointers N int i for i 0 i N i pointers i malloc 4 for i 0 i N i free pointers i for i 0 i N i pointers i malloc 56 Page 7 of 13 A Consider a malloc implementation that uses an implicit list with headers of size 8 bytes and no footers In order to keep payloads aligned to 8 bytes every block is always constrained to have size a multiple of 8 The header of each block stores the size of the block and since the 3 lowest order bits are guaranteed to be 0 the lowest order bit is used to store whether the block is allocated or free A first fit allocation policy is used If no unallocated block of a large enough size to service the request is found sbrk is called for the smallest multiple of 8 that can service the request No coalescing or block splitting is done NOTE You do NOT need to simplify any mathematical expressions Your final answer may include multilpliations additions and divisions 1 After the given code sample is run how many total bytes have been requested from sbrk 2 How many of those bytes are used for currently allocated blocks including internal …
View Full Document