Open In App

# 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;

```         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
(D) Deadlock avoidance requires knowledge of resource requirements a priori

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