# Operating System (Test 3)

## Gate Exam : Cs Computer Science And Information Technology

| Home | | Gate Exam | | Cs Computer Science And Information Technology | | Operating System | Operating System
| Operating System |
Q.1
The amount of ROM needed to implement a 4 bit multiplier is
A. 64 bits
B. 128 bits
C. 1 kbits
D. 2 kbits
Explaination / Solution:

For a 4 bit multiplier there are 24 × 24 = 28 = 256 combinations.
Output will contain 8 bits.
So the amount of ROM needed is 28 ×8 bits = 2Kbits

Workspace
Report
Q.2
A process executes the code fork (); fork (); fork (); The total number of child processes created is
A. 3
B. 4
C. 7
D. 8
Explaination / Solution:

If fork is called n times, there will be total 2n running processes including the parent process. So, there will be 2n -1 child processes.

Workspace
Report
Q.3
A multithreaded program P executes with x number of threads and uses y number of locks for ensuring mutual exclusion while operating on shared memory locations. All locks in the program are non-reentrant, i.e., if a thread holds a lock l, then it cannot re-acquire lock l without releasing it. If a thread is unable to acquire a lock, it blocks until the lock becomes available. The minimum value of x and the minimum value of y together for which execution of P can result in a deadlock are:
A. x = 1, y = 2
B. x =2, y=1
C. x = 2,y=2
D. x = 1, y = 1
Explaination / Solution:

As per given question, there 'x' number of threads and 'y' number of locks for ensuring mutual exclusion while operating on shared memory locations
Option (A): x=1;y=2
Means that 1 thread and 2 locks clearly showing that no deadlock situation
Option (B): x=2;y=1
After usage of lock by 1 thread, it can release that lock and then 2nd thread can be used that lock. So no deadlock
Option(C):x=2;y=2
Both threads can hold 1 lock and can wait for release of another lock
Option(D) x=1; y=1

Workspace
Report
Q.4
A file system with 300 GByte disk uses a file descriptor with 8 direct block addresses, 1 indirect block address and 1 doubly indirect block address. The size of each disk block is 128 Bytes and the size of each disk block address is 8 Bytes. The maximum possible file size in this file system is
A. 3 KBytes
B. 35 KBytes
C. 280 KBytes
D. dependent on the size of the disk
Explaination / Solution:

Each block size = 128 Bytes Disk block address = 8 Bytes ∴ Each disk can contain = 128/8 = 16 addresses Size due to 8 direct block addresses: 8 x 128 Size due to 1 indirect block address: 16 x 128 Size due to 1 doubly indirect block address: 16 x 16 x 128 Size due to 1 doubly indirect block address: 16 x 16 x 128 So, maximum possible file size: = 8×128 +16×128 +16×16×128=1024 + 2048 + 32768=35840 Bytes= 35KBytes

Workspace
Report
Q.5
Fetch_And_Add (X, i) is an atomic Read-Modify-Write instruction that reads the value of memory location X, increments it by the value i, and returns the old value of X. It is used in the pseudocode shown below to implement a busy-wait lock. L is an unsigned integer shared variable initialized to 0. The value of 0 corresponds to lock being available, while any nonzero value corresponds to the lock being not available.
AcquireLock(L){
L = 1;
}
Release Lock(L){
L = 0;
}
This implementation

A. fails as L can overflow
B. fails as L can take on a non-zero value when the lock is actually available
C. works correctly but may starve some processes
D. works correctly without starvation
Explaination / Solution:

1. Acquire lock (L) {
3. L = 1.
}
4. Release Lock (L) {
5. L = 0;
6. }
Let P and Q be two concurrent processes in the system currently executing as follows
P executes 1,2,3 then Q executes 1 and 2 then P executes 4,5,6 then L=0 now Q executes 3 by which L will be set to 1 and thereafter no process can set
L to zero, by which all the processes could starve.

Workspace
Report
Q.6
Consider the 3 process, P1, P2 and P3 shown in the table The completion order of the 3 processes under the policies FCFS and RR2 (round robin scheduling with CPU quantum of 2 time units) are
A. FCFS: P1, P2, P3 RR2: P1, P2, P3
B. FCFS: P1, P3, P2 RR2: P1, P3, P2
C. FCFS: P1, P2, P3 RR2: P1, P3, P2
D. FCFS: P1, P3, P2 RR2: P1, P2, P3
Explaination / Solution:

For FCFS Execution order will be order of Arrival time so it is P1,P2,P3 Next For RR with time quantum=2,the arrangement of Ready Queue will be as follows: RQ: P1,P2,P1,P3,P2,P1,P3,P2 This RQ itself shows the order of execution on CPU(Using Gantt Chart) and here it gives the completion order as P1,P3,P2 in Round Robin algorithm.

Workspace
Report
Q.7
Consider the methods used by processes P1 and P2 for accessing their critical sections whenever needed, as given below. The initial values of shared boolean variables S1 and S2 are randomly assigned. Which one of the following statements describes the properties achieved?

A. Mutual exclusion but not progress
B. Progress but not mutual exclusion
C. Neither mutual exclusion nor progress
D. Both mutual exclusion and progress
Explaination / Solution:
No Explaination.

Workspace
Report
Q.8
Which of the following statements are true?
I. Shortest remaining time first scheduling may cause starvation
II. Preemptive scheduling may cause starvation
III. Round robin is better than FCFS in terms of response time
A. I only
B. I and III only
C. II and III only
D. I, II and III
Explaination / Solution:
No Explaination.

Workspace
Report
Q.9
The program below uses six temporary variables a, b, c, d, e, f.
a = 1
b = 10
c = 20
d = a + b
e = c + d
f = c + e
b = c + e
e = b + f
d = 5 + e
return d + f
Assuming that all operations take their operands from registers, what is the minimum number of registers needed to execute thi s program without spilling?
A. 2
B. 3
C. 4
D. 6
Explaination / Solution:
No Explaination.

Workspace
Report
Q.10
Three concurrent processes X, Y, and Z execute three different code segments that access and update certain shared variables. Process X executes the P operation (i.e., wait) on semaphores a, b and c; process Y executes the P operation on semaphores b, c and d; process Z executes the P operation on semaphores c, d, and a before entering the respective code segments. After completing the execution of its code segment, each process invokes the V operation (i.e., signal) on its three semaphores. All semaphores are binary semaphores initialized to one. Which one of the following represents a deadlock-free order of invoking the P operations by the processes?
A. X : P (a) P (b) P (c) Y : P (b) P (c) P (d) Z: P (c) P (d) P (a)
B. X : P (b) P (a) P (c) Y : P (b) P (c) P (d) Z: P (a) P (c) P (d)
C. X : P (b) P (a) P (c) Y : P (c) P (b) P (d) Z: P (a) P (c) P (d)
D. X : P (a) P (b) P (c) Y : P (c) P (b) P (d) Z: P (c) P (d) P (a)