100% Guaranteed Results


CS330 – Mid Semester Exam Solved
$ 29.99
Category:

Description

5/5 – (1 vote)

Q1.
(i) (a), (b), (c), (d), (e) (ii) (c)
(iii) (a), (b), (c), (d), (e)
(iv) {(a), (b), (c) (e) } OR {(a), (c) (e)}
(v) (a), (d), (e)
Q2.
(i) False: A child created using vfork shares the page table pages and memory pages with the parent. So, TLB flush is not required as CR3 is not switched when child is scheduled after the parent.
(ii) False: Inverted page table mapping (PFN to virtual page address) is required to correctly implement shared mappings. For example, when a page is shared by two processes (say P, Q) and if P deletes the shared page, page table entry of P corresponding to the shared page is cleared. To update the page table mapping of Q (as the page no longer exists) a reverse mapping is required.
(iii) True: If the user process accesses a virtual address outside the virtual address areas allocated to it by the OS, the OS can kill the process without changing any page table mapping. If cleaning up page tables during the process termination is considered as changing the entry, the answer can be False (To be explicitly mentioned).
(iv) True: If swapping is required to free PFNs to handle the page fault, Disk I/O is required (assuming swap device is part of a hard disk). Therefore, it is prudent to put the faulting process into waiting state.
(v) True: In a scenario when all accesses are to unique pages.
var1=0 var2=0 var1=0 var2=0 var1=0 var2=0 var1=3 var2=3 var1=3 var2=3
Explanation:
Before entering the for loop, pid = M, where M is the PID of main process.
For loop iteration 1 (i=0)
“If” condition (line #17) is false for both main process and C1, so execl is not invoked var2 = 1 both in main process and C1
For loop iteration 2 (i=1)
“If” condition (line #17) is false only for main process. All other processes C1, C2, C3 execute p2 through execl call. Therefore, there will be three lines of output printing the values of var1 and var2 in p2.c which is zero. var2 = 2 in main process. All other processes never come back here.
For loop iteration 3 (i=2)
“If” condition (line #17) is false for both main process and C4, so execl is not invoked var2 = 3 both in main process and C4
Both main process and C4 exit the for loop and sleep for one second. In the mean time, C1, C2 and C3 execute the p2.c program binary and as a result var1=0 var2=0 is printed thrice. After one second, main process and C4 print the values of var1 = 3 and var2 = 3 (printed twice).
Q4.
(i) 253 bytes
(ii) 230 entries
# of entries in L4 = # of page table pages in L3 = 210
# of entries in L3 = # of page table pages in L2 = 210 × 210
# of entries in L2 = 210 × 210 × 210 = 230
(iii) Given, Page table entry size = 64 bits, Page size = 8KB, Max PA = 257 bytes # of physical pages = 257 ÷ 213 = 244
Therefore, # of bits required in PTE entries to specify the next level address = 44
# of flag bits = 5
So, unused bits = 64 – 5 – 44 = 15 bits
(iv) Virtual address size = 4GB = 232 ÷ 213 = 219 pages
⇒ # of entries required at L1 = 219
Best case (3 Marks)
L1: 219 entries require 29 page table pages
L2: 29 entries require 1 page table page
L3: 1 entry require 1 page table page
L4: 1 entry require 1 page table page
Total page table memory = (29 + 1 + 1 + 1) × 8 KB
Worst case (4 Marks)
L1: 219 entries can be spread across 219 different page table pages (max. page table pages =
230)
L2: 219 entries can be spread across 219 different page table pages (max. page table pages =
220)
L3: 219 entries can be spread across 210 different page table pages (max. page table pages =
210)
L4: 210 entries require 1 page table page (max. page table page = 1) Total page table memory = (219 + 219 + 210 + 1) × 8 KB
2
Q5.
(i) The child process will successfully complete. The parent process will access an invalid memorylocation causing segfault. This is true irrespective of order of execution as value of ptr is NULL in parent even if the child executes first and allocates legitimate address for ptr.
(ii) Introduction of wait() system call does not change the behavior of the parent, it still crashes. Because, the parent memory state is not impacted by the child’s execution.
(ii) The parent will print ’A’ and both the programs will terminate successfully. vfork() suspends the parent and executes the child using the parent’s pages tables. Therefore, the parent will see all the changes in memory layout done by the child.
3

Reviews

There are no reviews yet.

Be the first to review “CS330 – Mid Semester Exam Solved”

Your email address will not be published. Required fields are marked *

Related products