Docsity

CMPSCI 377 Sample Exam: Memory Management and Address Spaces - Prof. Mark Corner, Quizzes of Operating Systems

Partial preview of the text

Download CMPSCI 377 Sample Exam: Memory Management and Address Spaces - Prof. Mark Corner and more Quizzes Operating Systems in PDF only on Docsity!

CMPSCI 377 Sample Exam

**This sample midterm is not to scale: there will be more short answer and true false questions.

  1. Short Answer** a) Explain why modern operating systems use a hierarchical multi-level page tables b) What does TLB stand for and how does it make a machine faster? c) d) Explain the generational hypothesis.

2. Memory Management Given the following code: *char ptr = malloc (10) free ptr; free ptr; The allocator you wrote for project two will probably crash. This is referred to as a “double free” and is actually a frequent programming error. Some allocators can handle this kind of error gracefully. This is what my free code looks like (some details are omitted, but assume this works): free(void *ptr){ BibopHeader *bbh FreeObject *fo_ptr = (FreeObject *) ptr; bbh= find_bbheader (ptr); unsigned int num_objects = maxobjects(bbh); // Gives number of possible objects in page // A *((FreeObject **)fo_ptr) = bbh->_freeList; bbh->_freeList = fo_ptr; // B bbh->_available++; // Free and unlink the page if it is empty free_page_if_empty(bbh); }

3. Address Spaces Consider a computer with the following properties:

  • 32 - bit addresses, byte addressing
  • #define PAGE_SIZE = 256= 2^
  • A page table entry occupies 4 bytes Consider a program with valid addresses in two ranges: 0x00000000->0x00008000 and 0xffffbfff->0xffffffff are occupied. Hint: 0x8000 is 2^15 and 0xffffffff – 0xffffbfff = 0x4000 = 2^ a) If single level page tables are used, how much space does the table consume? b) If a three level page table with 12 bits for level 1, 4 bits for level 2, and 8 bits for level 3, how much space is used?