CS代考 ECE344, Fall 2020

Operating Systems Quiz 4 Duration: 1 hour
Examiners: M. Stumm and A. Goel
Instructions
Examination Aids: This is an open book exam.

Copyright By PowCoder代写 加微信 powcoder

All questions have been provided in this exam booklet. You need to provide your answers on Quercus.
If any of the questions appear unclear or ambiguous to you, then make any assumptions you need, state them and answer the question that way. If you believe there is an error, state what the error is, fix it, and respond as if fixed.
Please be brief and specific as possible. Clear, concise answers will be given higher marks than vague, wordy answers. Marks will be deducted for incorrect statements in an answer.
Work independently.
ECE344, Fall 2020
MARKING GUIDE Q1: (10) Q2: (8) Q3: (6) Q4: (6)
TOTAL: (30)
Page 1 of 6

Operating Systems Quiz 4 ECE344, Fall 2020 Question 1. TLB [10 MARKS]
Consider the following program:
int y = 5;
int main(int argc, const char * argv[]) {
int z = y + argc;
return printf(“z = %d\n”, z); }
You examine the executable of this program using the objdump program. The table below shows partial information related to the virtual address space layout of the program.
Section or Function
.data .rodata main printf
Program strings are stored in the .rodata section. and the stack grows down.
Virtual Address Permission
0x00600000 RW
0x00400000 R
0x004011e8 RX
0x004024b0 RX
The top of the stack region is located at address 0x80000000
You run this program on a processor that uses 4KB pages and 20-bit virtual page numbers. The processor uses a split TLB, one for instructions (I-TLB) and one for data (D-TLB). The TLB entry format is shown below:
VPN PID PFN U W X V
The TLB entry is tagged with a 4 bit PID. V is the valid bit, X is the executable bit, W is the writeable bit (i.e., not
readonly), and U is an unused bit (always 0).
When you run the program shown above, assume its process id, PID = (your-student-number modulo 4) + 1. This process can complete execution within one time quantum. Show the TLB entries that will be generated by this process, and state whether each entry will be loaded into the I-TLB or D-TLB. Format your answer as follows (you don¡¯t need to show the comment):
Step 1: 0x0BADBEEF1337 to I-TLB // TLB entry 0x0BADBEEF1337 loaded into I-TLB Step 2: 0x42069ECE344F to D-TLB
When you need to allocate a new physical page, start from 0x00200000 and work your way up, e.g., the first physical page you allocate should be 0x00200000, and the next page should be 0x00201000, etc. You must allocate the physical pages in the same order that the process requests them; assume that out-of-order execution is disabled on the processor. Hint: the first page that a process requests is a stack page.
Page 2 of 6

Operating Systems Quiz 4 ECE344, Fall 2020 Question 2. Demand Paging [8 MARKS]
A processor with a software-managed TLB provides the following privileged instructions (shown in pseudocode):
1. tlb_read_entry(vaddr) // reads TLB entry corresponding to vaddr 2. tlb_evict_entry(vaddr) // evicts TLB entry corresponding to vaddr 3. tlb_write_entry(vaddr, paddr, // updates TLB entry corresponding to vaddr
4. tlb_flush()
// flushes entire TLB
Assume that the TLB is not tagged. For each instruction, describe a demand paging related event under which the operating system will invoke the instruction. You should start each answer with ¡°OS will …¡±, e.g., ¡°OS will read a TLB entry …¡±. Do not write more than 1 or 2 sentences, or else marks will be deducted.
Page 3 of 6

Operating Systems Quiz 4 ECE344, Fall 2020 Question 3. Virtual Memory Implementation [6 MARKS]
Part(a) [3MARKS]WhichofthefollowingoperationsmaycausechangestotheOScoremap?Circleallanswers that apply.
1. Program reads from a copy-on-write page that is in memory. 2. Program loads a dynamic library.
3. Context switch occurs.
4. Program invokes malloc().
5. OS writes dirty TLB entry to the page table. 6. Page fault handler evicts a page.
Part(b) [3MARKS]Whichofthefollowingarebenefitsofcopy-on-writefork()?Circleallanswersthatapply.
1. Makes inter-process communication possible.
2. Speeds up the process of program creation.
3. Reduces memory usage.
4. Child process shares page table with parent.
5. Parent process¡¯s page table does not require any changes.
6. Speeds up eviction of COW frames compared to non-COW frames.
Page 4 of 6

Operating Systems Quiz 4 ECE344, Fall 2020 Question 4. Processes and Virtual Memory [6 MARKS]
Part(a) [3MARKS]WhenyouwriteaprogramthatdereferencesaNULLpointer(e.g.,int *a = NULL; *a = 1;),clearlyexplainwhyyourprogramcrashes.Hint:thinkabouthowdemandpagingworks.
Part (b) [3 MARKS] You have implemented a hash table using linked lists. You decide that this hash table should be shared by two processes. You have learned that the mmap() system call allocates a new virtual memory region, and it also allows two processes to share the same physical memory. You use this call in each process to allocate a virtual memory region and also ensure that these regions map to the same physical memory. Now you implement the hash table using this memory. When any one process uses this hash table, the hash table works correctly. However, when both processes use this hash table (lookup entries or insert entries), then the hash table does not work correctly. You test the same implementation using two threads in the same process and that works correctly.
What may be the problem with the two process implementation? Describe a method for solving the problem?
Page 5 of 6

Operating Systems Quiz 4 ECE344, Fall 2020 [Use the space below for rough work.]
Page 6 of 6 END OF EXAMINATION