# Operating Systems | Set 11

Following questions have been asked in GATE 2008 CS exam. 1) A process executes the following code
`  for (i = 0; i < n; i++) fork(); `
The total number of child processes created is (A) n (B) 2^n - 1 (C) 2^n (D) 2^(n+1) - 1; Answer (B)
```         F0       // There will be 1 child process created by first fork
/     \
F1      F1    // There will be 2 child processes created by second fork
/  \    /  \
F2   F2  F2   F2  // There will be 4 child processes created by third fork
/ \   / \ / \  / \
...............   // and so on
```
If we sum all levels of above tree for i = 0 to n-1, we get 2^n - 1. So there will be 2^n â€“ 1 child processes. Also see this post for more details.

2) Which of the following is NOT true of deadlock prevention and deadlock avoidance schemes? (A) In deadlock prevention, the request for resources is always granted if the resulting state is safe (B) In deadlock avoidance, the request for resources is always granted if the result state is safe (C) Deadlock avoidance is less restrictive than deadlock prevention (D) Deadlock avoidance requires knowledge of resource requirements a priori Answer (A) Deadlock prevention scheme handles deadlock by making sure that one of the four necessary conditions don't occur. In deadlock prevention, the request for a resource may not be granted even if the resulting state is safe. (See the Galvin book slides for more details)

3) A processor uses 36 bit physical addresses and 32 bit virtual addresses, with a page frame size of 4 Kbytes. Each page table entry is of size 4 bytes. A three level page table is used for virtual to physical address translation, where the virtual address is used as follows â€¢ Bits 30-31 are used to index into the first level page table â€¢ Bits 21-29 are used to index into the second level page table â€¢ Bits 12-20 are used to index into the third level page table, and â€¢ Bits 0-11 are used as offset within the page The number of bits required for addressing the next level page table (or page frame) in the page table entry of the first, second and third level page tables are respectively (A) 20, 20 and 20 (B) 24, 24 and 24 (C) 24, 24 and 20 (D) 25, 25 and 24 Answer (D) Virtual address size = 32 bits Physical address size = 36 bits Physical memory size = 2^36 bytes Page frame size = 4K bytes = 2^12 bytes No. of bits required to access physical memory frame = 36 - 12 = 24 So in third level of page table, 24 bits are required to access an entry. 9 bits of virtual address are used to access second level page table entry and size of pages in second level is 4 bytes. So size of second level page table is (2^9)*4 = 2^11 bytes. It means there are (2^36)/(2^11) possible locations to store this page table. Therefore the second page table requires 25 bits to address it. Similarly, the third page table needs 25 bits to address it. Please see GATE Corner for all previous year paper/solutions/explanations, syllabus, important dates, notes, etc. Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above.

Previous
Next