SlideShare a Scribd company logo
1 of 4
Download to read offline
University of Waterloo
Midterm Examination #2 Model Solution
Spring, 2009
1. (11 total marks)
Consider a virtual memory system that uses multi-level paging for address translation. Virtual ad-
dresses and physical addresses are 64 bits long. The page size is 1 MB (220
bytes). The size of a page
table entry is 16 (24
) bytes. Each individual page table, at each level, must fit in a single frame.
a. (2 marks) How many bits of each virtual address are needed to represent the page offset?
20 bits (because the page size is 220
bytes).
b.(2 marks) What is the maximum number of entries in an individual page table?
220
24
= 216
entries
c. (4 marks) What is the minimum number of levels of page tables that will be required for virtual-
to-physical translation in this system? Show your work for possible partial credit.
20 of 64 bits are used for the offset, leaving 44 bits for page numbers. Each level of
page tables will require a 16 bit page number (because 216
is the maximum size of each
page table). Thus, a total of 3 levels of page tables will be required.
d. (3 marks) Suppose that a particular process uses only 128 MB (227
bytes) of virtual memory,
with a virtual address range from 0 to 227
− 1. How many individual page tables, at each level,
will be required to translate this process’ address space? Your answer should be of this form:
Level 1: X page tables
Level 2: Y page tables
...
Level N: Z page tables
Show your work for possible partial credit.
The address space for this process has only 227
/220
= 27
pages. A single level 3 page
table can have up to 216
entries, so only a single page table will be needed at level 3.
Only a single page table entry will be needed at levels 1 and 2 to index the level 3 page
table.
Level 1: 1 page table
Level 2: 1 page table
Level 3: 1 page table
CS350 1 of 4
2. (12 marks)
The following diagram, from the lecture notes, illustrates the virtual address space of a MIPS process.
user space kernel space
2 GB 2 GB
0x00000000 0xffffffff0x80000000
0xa0000000
0xc0000000
kseg0 kseg1 kseg2kuseg
1 GB0.5GB0.5GB
unmapped, cached unmapped, uncached
TLB mapped
Suppose that the TLB in the MIPS MMU contains the following entries. For each entry, only the
virtual page number and physical frame number are shown. Assume that all of the entries are valid.
virtual
entry page frame
number number number
0 0x10000 0x08343
1 0x10004 0x08344
2 0x00400 0x0100a
3 0x7ffff 0x01112
4 0x7fffe 0x01113
5 0x00402 0x0600b
6 0x00404 0x01114
For each of the following physical addresses, indicate which virtual address (or addresses) will translate
to that physical address. If there is more than one virtual address that translates to the given physical
addresses, you should list all of the virtual addresses. If there are no virtual addresses that translate
to the given physical address, you should write “No Virtual Addresses”.
a. (3 marks) 0x01113fa0
0x7fffefa0, 0x81113fa0, 0xa1113fa0
b. (3 marks) 0x0100a088
0x00400088, 0x8100a088, 0xa100a088
c. (3 marks) 0x0100b014
0x8100b014, 0xa100b014
d. (3 marks) 0x08343ffc
0x10000ffc, 0x88343ffc, 0xa8343ffc
CS350 2 of 4
3. (12 total marks)
Consider a small system in which there are two processes, PA and PB. Virtual and physical addresses
in this system are only 16 bits long. The page size is 256 (28
) bytes. The diagram below shows the
the current page tables for the two processes. In addition, the diagram also shows the kernel’s current
core map, which lists the contents of each physical frame.
Page Table for Process PA
Page Frame
Number Number Valid Use Dirty
0 1 1 1 0
1 3 0 0 0
2 6 0 0 0
3 4 1 0 1
4 5 1 1 0
5 7 0 0 0
Page Table for Process PB
Page Frame
Number Number Valid Use Dirty
0 2 1 1 0
1 7 1 0 0
2 0 1 0 0
3 3 1 1 0
4 6 1 0 0
5 1 0 0 0
6 0 0 0 0
Core Map
Frame Process Page
Number ID Number
0 PB 2
1 PA 0 ← clock pointer
2 PB 0
3 PB 3
4 PA 3
5 PA 4
6 PB 4
7 PB 1
Suppose that the kernel uses a global clock replacement algorithm. The current position of the clock
algorithm’s victim pointer is shown in the core map. The pointer moves down (towards larger frame
numbers).
Suppose that PA is the currently running process. The value of the program counter is 0x0144, and
the instruction at that address is a “store” instruction which will write the contents of a register to
memory at virtual address 0x057c.
a. (4 marks)
Will any page faults occur when the “store” instruction is fetched and executed by the processor?
If so, specify how many page faults will occur, and specify the virtual page(s) that the processor
will attempt to use that will result in the page fault(s). (For each page, be sure to specify both
the process ID and the page number.) If there are no page faults, write “NO PAGE FAULTS”.
Two page faults will occur. Fetching the “store” instruction will cause a page fault for
PA’s page 0x01, and storing the register contents will cause a page fault for PA’s page
0x05.
b. (2 marks)
Will any pages be written from memory to secondary storage as a result of these page fault(s)?
If so, indicate which page(s). (For each page, be sure to specify both the process ID and the page
number.) If there are no page faults, or if no pages are written, write “NO PAGES WRITTEN”.
The page fault for PA’s page 0x01 will result in the eviction of PA’s page 0x3. Since
that page is dirty, it will have to be written to secondary storage. The page fault for
PA’s page 0x05 will result in the eviction of PB’s page 0x04. Since that page is not
dirty, this page will not be written to secondary storage.
CS350 3 of 4
c. (6 marks)
Show what that core map will look like after the processor has successfully executed the “store”
instruction, i.e., after any page fault(s) have occurred. Be sure to indicate the position of the
clock pointer.
Core Map
Frame Process Page
Number ID Number
0 PB 2
1 PA 0
2 PB 0
3 PB 3
4 PA 1
5 PA 4
6 PA 5
7 PB 1 ← clock pointer
4. (15 marks)
a. (5 marks)
Indicate (by circling them) which of the following pieces of information can be found in the ELF
file.
• the number of pages in the text (code) segment
• the number of pages in the stack segment
• the starting virtual address of the text (code) segment
• the starting virtual address of the data segment
• the starting physical address of the data segment
b. (4 marks)
Indicate (by circling them) which of the following events will cause OS/161 to create a trap frame
• a system call
• a timer interrupt
• a call to thread exit()
• returning from a system call
c. (6 marks)
Please indicate whether each of the following statements is true or false by writing “TRUE” or
“FALSE” next to the statement.
• Once a thread has acquired a lock (using lock acquire()), it cannot be preempted by the
scheduler until it has released the lock by calling lock release FALSE
• Peterson’s algorithm can be used to enforce mutual exclusion on a multiprocessor. TRUE
• A test-and-set instruction can be used to enforce mutual exclusion on a multiprocessor.
TRUE
• It is possible to have deadlock in a system in which there is only a single (single-threaded)
process. TRUE
• “Belady’s anomaly” refers to a situation in which a process with a smaller virtual address space
experiences more page faults than a process with a larger virtual address space. FALSE
• Exceptions cause the processor to switch to privileged execution mode. TRUE
CS350 4 of 4

More Related Content

Similar to University of Waterloo Midterm Exam Model Solution

Address translation-mechanism-of-80386 by aniket bhute
Address translation-mechanism-of-80386 by aniket bhuteAddress translation-mechanism-of-80386 by aniket bhute
Address translation-mechanism-of-80386 by aniket bhuteAniket Bhute
 
Csc4320 chapter 8 2
Csc4320 chapter 8 2Csc4320 chapter 8 2
Csc4320 chapter 8 2bshikhar13
 
Advance computer architecture
Advance computer architectureAdvance computer architecture
Advance computer architecturesuma1991
 
Segmentation Faults, Page Faults, Processes, Threads, and Tasks
Segmentation Faults, Page Faults, Processes, Threads, and TasksSegmentation Faults, Page Faults, Processes, Threads, and Tasks
Segmentation Faults, Page Faults, Processes, Threads, and TasksDavid Evans
 
Ecet 330 final exam new 2016
Ecet 330 final exam new 2016Ecet 330 final exam new 2016
Ecet 330 final exam new 2016sergejsvolkovs10
 
Ecet 330 final exam new 2016
Ecet 330 final exam new 2016Ecet 330 final exam new 2016
Ecet 330 final exam new 2016powellabril
 
Ecet 330 final exam new 2016
Ecet 330 final exam new 2016Ecet 330 final exam new 2016
Ecet 330 final exam new 2016powellabril
 
The reasons why 64-bit programs require more stack memory
The reasons why 64-bit programs require more stack memoryThe reasons why 64-bit programs require more stack memory
The reasons why 64-bit programs require more stack memoryPVS-Studio
 
Linux Kernel Booting Process (2) - For NLKB
Linux Kernel Booting Process (2) - For NLKBLinux Kernel Booting Process (2) - For NLKB
Linux Kernel Booting Process (2) - For NLKBshimosawa
 
Operating System- Multilevel Paging, Inverted Page Table
Operating System- Multilevel Paging, Inverted Page TableOperating System- Multilevel Paging, Inverted Page Table
Operating System- Multilevel Paging, Inverted Page TableZishan Mohsin
 
XPDS16: Keeping coherency on ARM - Julien Grall, ARM
XPDS16: Keeping coherency on ARM - Julien Grall, ARMXPDS16: Keeping coherency on ARM - Julien Grall, ARM
XPDS16: Keeping coherency on ARM - Julien Grall, ARMThe Linux Foundation
 
Memory layout in C++ vis a-vis polymorphism and padding bits
Memory layout in C++ vis a-vis polymorphism and padding bitsMemory layout in C++ vis a-vis polymorphism and padding bits
Memory layout in C++ vis a-vis polymorphism and padding bitsSomenath Mukhopadhyay
 
lecture16-recap-questions-and-answers.pdf
lecture16-recap-questions-and-answers.pdflecture16-recap-questions-and-answers.pdf
lecture16-recap-questions-and-answers.pdfAyushKumar93531
 
3 organization of intel 8086
3 organization of intel 80863 organization of intel 8086
3 organization of intel 8086ELIMENG
 
Interview with Anatoliy Kuznetsov, the author of BitMagic C++ library
Interview with Anatoliy Kuznetsov, the author of BitMagic C++ libraryInterview with Anatoliy Kuznetsov, the author of BitMagic C++ library
Interview with Anatoliy Kuznetsov, the author of BitMagic C++ libraryPVS-Studio
 
扩展世界上最大的图片Blog社区
扩展世界上最大的图片Blog社区扩展世界上最大的图片Blog社区
扩展世界上最大的图片Blog社区yiditushe
 

Similar to University of Waterloo Midterm Exam Model Solution (20)

Address translation-mechanism-of-80386 by aniket bhute
Address translation-mechanism-of-80386 by aniket bhuteAddress translation-mechanism-of-80386 by aniket bhute
Address translation-mechanism-of-80386 by aniket bhute
 
Csc4320 chapter 8 2
Csc4320 chapter 8 2Csc4320 chapter 8 2
Csc4320 chapter 8 2
 
Advance computer architecture
Advance computer architectureAdvance computer architecture
Advance computer architecture
 
Segmentation Faults, Page Faults, Processes, Threads, and Tasks
Segmentation Faults, Page Faults, Processes, Threads, and TasksSegmentation Faults, Page Faults, Processes, Threads, and Tasks
Segmentation Faults, Page Faults, Processes, Threads, and Tasks
 
Ecet 330 final exam new 2016
Ecet 330 final exam new 2016Ecet 330 final exam new 2016
Ecet 330 final exam new 2016
 
Ecet 330 final exam new 2016
Ecet 330 final exam new 2016Ecet 330 final exam new 2016
Ecet 330 final exam new 2016
 
Ecet 330 final exam new 2016
Ecet 330 final exam new 2016Ecet 330 final exam new 2016
Ecet 330 final exam new 2016
 
The reasons why 64-bit programs require more stack memory
The reasons why 64-bit programs require more stack memoryThe reasons why 64-bit programs require more stack memory
The reasons why 64-bit programs require more stack memory
 
Linux Kernel Booting Process (2) - For NLKB
Linux Kernel Booting Process (2) - For NLKBLinux Kernel Booting Process (2) - For NLKB
Linux Kernel Booting Process (2) - For NLKB
 
Risc vs cisc
Risc vs ciscRisc vs cisc
Risc vs cisc
 
Operating System- Multilevel Paging, Inverted Page Table
Operating System- Multilevel Paging, Inverted Page TableOperating System- Multilevel Paging, Inverted Page Table
Operating System- Multilevel Paging, Inverted Page Table
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
XPDS16: Keeping coherency on ARM - Julien Grall, ARM
XPDS16: Keeping coherency on ARM - Julien Grall, ARMXPDS16: Keeping coherency on ARM - Julien Grall, ARM
XPDS16: Keeping coherency on ARM - Julien Grall, ARM
 
Memory layout in C++ vis a-vis polymorphism and padding bits
Memory layout in C++ vis a-vis polymorphism and padding bitsMemory layout in C++ vis a-vis polymorphism and padding bits
Memory layout in C++ vis a-vis polymorphism and padding bits
 
lecture16-recap-questions-and-answers.pdf
lecture16-recap-questions-and-answers.pdflecture16-recap-questions-and-answers.pdf
lecture16-recap-questions-and-answers.pdf
 
Summing up 33_s
Summing up 33_sSumming up 33_s
Summing up 33_s
 
3 organization of intel 8086
3 organization of intel 80863 organization of intel 8086
3 organization of intel 8086
 
Interview with Anatoliy Kuznetsov, the author of BitMagic C++ library
Interview with Anatoliy Kuznetsov, the author of BitMagic C++ libraryInterview with Anatoliy Kuznetsov, the author of BitMagic C++ library
Interview with Anatoliy Kuznetsov, the author of BitMagic C++ library
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
扩展世界上最大的图片Blog社区
扩展世界上最大的图片Blog社区扩展世界上最大的图片Blog社区
扩展世界上最大的图片Blog社区
 

Recently uploaded

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Recently uploaded (20)

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

University of Waterloo Midterm Exam Model Solution

  • 1. University of Waterloo Midterm Examination #2 Model Solution Spring, 2009 1. (11 total marks) Consider a virtual memory system that uses multi-level paging for address translation. Virtual ad- dresses and physical addresses are 64 bits long. The page size is 1 MB (220 bytes). The size of a page table entry is 16 (24 ) bytes. Each individual page table, at each level, must fit in a single frame. a. (2 marks) How many bits of each virtual address are needed to represent the page offset? 20 bits (because the page size is 220 bytes). b.(2 marks) What is the maximum number of entries in an individual page table? 220 24 = 216 entries c. (4 marks) What is the minimum number of levels of page tables that will be required for virtual- to-physical translation in this system? Show your work for possible partial credit. 20 of 64 bits are used for the offset, leaving 44 bits for page numbers. Each level of page tables will require a 16 bit page number (because 216 is the maximum size of each page table). Thus, a total of 3 levels of page tables will be required. d. (3 marks) Suppose that a particular process uses only 128 MB (227 bytes) of virtual memory, with a virtual address range from 0 to 227 − 1. How many individual page tables, at each level, will be required to translate this process’ address space? Your answer should be of this form: Level 1: X page tables Level 2: Y page tables ... Level N: Z page tables Show your work for possible partial credit. The address space for this process has only 227 /220 = 27 pages. A single level 3 page table can have up to 216 entries, so only a single page table will be needed at level 3. Only a single page table entry will be needed at levels 1 and 2 to index the level 3 page table. Level 1: 1 page table Level 2: 1 page table Level 3: 1 page table CS350 1 of 4
  • 2. 2. (12 marks) The following diagram, from the lecture notes, illustrates the virtual address space of a MIPS process. user space kernel space 2 GB 2 GB 0x00000000 0xffffffff0x80000000 0xa0000000 0xc0000000 kseg0 kseg1 kseg2kuseg 1 GB0.5GB0.5GB unmapped, cached unmapped, uncached TLB mapped Suppose that the TLB in the MIPS MMU contains the following entries. For each entry, only the virtual page number and physical frame number are shown. Assume that all of the entries are valid. virtual entry page frame number number number 0 0x10000 0x08343 1 0x10004 0x08344 2 0x00400 0x0100a 3 0x7ffff 0x01112 4 0x7fffe 0x01113 5 0x00402 0x0600b 6 0x00404 0x01114 For each of the following physical addresses, indicate which virtual address (or addresses) will translate to that physical address. If there is more than one virtual address that translates to the given physical addresses, you should list all of the virtual addresses. If there are no virtual addresses that translate to the given physical address, you should write “No Virtual Addresses”. a. (3 marks) 0x01113fa0 0x7fffefa0, 0x81113fa0, 0xa1113fa0 b. (3 marks) 0x0100a088 0x00400088, 0x8100a088, 0xa100a088 c. (3 marks) 0x0100b014 0x8100b014, 0xa100b014 d. (3 marks) 0x08343ffc 0x10000ffc, 0x88343ffc, 0xa8343ffc CS350 2 of 4
  • 3. 3. (12 total marks) Consider a small system in which there are two processes, PA and PB. Virtual and physical addresses in this system are only 16 bits long. The page size is 256 (28 ) bytes. The diagram below shows the the current page tables for the two processes. In addition, the diagram also shows the kernel’s current core map, which lists the contents of each physical frame. Page Table for Process PA Page Frame Number Number Valid Use Dirty 0 1 1 1 0 1 3 0 0 0 2 6 0 0 0 3 4 1 0 1 4 5 1 1 0 5 7 0 0 0 Page Table for Process PB Page Frame Number Number Valid Use Dirty 0 2 1 1 0 1 7 1 0 0 2 0 1 0 0 3 3 1 1 0 4 6 1 0 0 5 1 0 0 0 6 0 0 0 0 Core Map Frame Process Page Number ID Number 0 PB 2 1 PA 0 ← clock pointer 2 PB 0 3 PB 3 4 PA 3 5 PA 4 6 PB 4 7 PB 1 Suppose that the kernel uses a global clock replacement algorithm. The current position of the clock algorithm’s victim pointer is shown in the core map. The pointer moves down (towards larger frame numbers). Suppose that PA is the currently running process. The value of the program counter is 0x0144, and the instruction at that address is a “store” instruction which will write the contents of a register to memory at virtual address 0x057c. a. (4 marks) Will any page faults occur when the “store” instruction is fetched and executed by the processor? If so, specify how many page faults will occur, and specify the virtual page(s) that the processor will attempt to use that will result in the page fault(s). (For each page, be sure to specify both the process ID and the page number.) If there are no page faults, write “NO PAGE FAULTS”. Two page faults will occur. Fetching the “store” instruction will cause a page fault for PA’s page 0x01, and storing the register contents will cause a page fault for PA’s page 0x05. b. (2 marks) Will any pages be written from memory to secondary storage as a result of these page fault(s)? If so, indicate which page(s). (For each page, be sure to specify both the process ID and the page number.) If there are no page faults, or if no pages are written, write “NO PAGES WRITTEN”. The page fault for PA’s page 0x01 will result in the eviction of PA’s page 0x3. Since that page is dirty, it will have to be written to secondary storage. The page fault for PA’s page 0x05 will result in the eviction of PB’s page 0x04. Since that page is not dirty, this page will not be written to secondary storage. CS350 3 of 4
  • 4. c. (6 marks) Show what that core map will look like after the processor has successfully executed the “store” instruction, i.e., after any page fault(s) have occurred. Be sure to indicate the position of the clock pointer. Core Map Frame Process Page Number ID Number 0 PB 2 1 PA 0 2 PB 0 3 PB 3 4 PA 1 5 PA 4 6 PA 5 7 PB 1 ← clock pointer 4. (15 marks) a. (5 marks) Indicate (by circling them) which of the following pieces of information can be found in the ELF file. • the number of pages in the text (code) segment • the number of pages in the stack segment • the starting virtual address of the text (code) segment • the starting virtual address of the data segment • the starting physical address of the data segment b. (4 marks) Indicate (by circling them) which of the following events will cause OS/161 to create a trap frame • a system call • a timer interrupt • a call to thread exit() • returning from a system call c. (6 marks) Please indicate whether each of the following statements is true or false by writing “TRUE” or “FALSE” next to the statement. • Once a thread has acquired a lock (using lock acquire()), it cannot be preempted by the scheduler until it has released the lock by calling lock release FALSE • Peterson’s algorithm can be used to enforce mutual exclusion on a multiprocessor. TRUE • A test-and-set instruction can be used to enforce mutual exclusion on a multiprocessor. TRUE • It is possible to have deadlock in a system in which there is only a single (single-threaded) process. TRUE • “Belady’s anomaly” refers to a situation in which a process with a smaller virtual address space experiences more page faults than a process with a larger virtual address space. FALSE • Exceptions cause the processor to switch to privileged execution mode. TRUE CS350 4 of 4