Operating System GATE previous year questions with answer
Ques 27 Gate 2017 Set-2
The read access times and the hit ratios for different caches in a memory hierarchy are as given below:
| Cache | Read Access Time (In Nanosecond) |
Hit Ratio |
|---|---|---|
| I-Cache | 2 | 0.8 |
| D-Cache | 2 | 0.9 |
| L2-Cache | 8 | 0.9 |
The read access time of main memory in 90 nanoseconds. Assume that the caches use the referred-word-first read policy and the writeback policy. Assume that all the caches are direct mapped caches. Assume that the dirty bit is always 0 for all the blocks in the caches. In execution of a program, 60% od memory reads are for instruction fetch and 40% are for memory operand fetch. The average read access time in nanoseconds (up to 2 decimal places) is _________
Ques 28 Gate 2017 Set-2
A system shares 9 tape drives. The current allocation and maximum requirement of tape drives for 3 processes are shown below:
| Process | Allocation Time | Maximum Requirement |
|---|---|---|
| P1 | 3 | 7 |
| P2 | 1 | 6 |
| P3 | 3 | 5 |
Which of the following best describes the current state of the system?
Given:
Total number of tape drives = 9
Processes: P1, P2, P3
Allocation: P1 = 3, P2 = 1, P3 = 3
Max Requirement: P1 = 7, P2 = 6, P3 = 5
To find:
Whether the current state of the system is Safe/Not Safe and Deadlocked/Not Deadlocked.
Solution:
First, let me calculate the total allocated tape drives.
Total allocated = 3 + 1 + 3 = 7
Now let me find the currently available tape drives.
Available = Total - Total allocated = 9 - 7 = 2
Next, I need to calculate the remaining Need for each process using Need = Max - Allocation.
For P1: Need = 7 - 3 = 4
For P2: Need = 6 - 1 = 5
For P3: Need = 5 - 3 = 2
Now let me check which process can be satisfied with Available = 2.
Checking P1: Need(P1) = 4 > Available (2), so P1 cannot execute right now.
Checking P2: Need(P2) = 5 > Available (2), so P2 cannot execute right now.
Checking P3: Need(P3) = 2 ≤ Available (2), so P3 can execute and complete.
Once P3 finishes, it releases its allocated tape drives.
New Available = 2 + Allocation of P3 = 2 + 3 = 5
Now check the remaining processes with Available = 5.
Checking P1: Need(P1) = 4 ≤ Available (5), so P1 can run and complete.
Once P1 finishes, it releases its allocated drives.
New Available = 5 + Allocation of P1 = 5 + 3 = 8
Finally, check P2.
Need(P2) = 5 ≤ Available (8), so P2 can also finish.
A safe sequence exists: <P3, P1, P2>.
Since a safe sequence exists, the system is in a Safe state.
By definition, if a system is in a safe state, it is definitely Not Deadlocked.
Answer:
(B) Safe, Not Deadlocked
Ques 29 Gate 2017 Set-2
Which of the following is/are shared by all the threads in a process?
I. Program Counter
II. Stack
III. Address space
IV. Registers
Given:
Items related to threads in a process:
I. Program Counter
II. Stack
III. Address space
IV. Registers
To find:
Which of these is/are shared by all the threads in a process.
Solution:
Let me recall what is unique to a thread and what is shared among threads of the same process.
A thread is a basic unit of CPU utilization, and each thread must have its own execution context.
So each thread needs its own Program Counter to keep track of which instruction to execute next.
Each thread also needs its own set of CPU registers to hold temporary values.
And each thread needs its own private Stack for local variables and function call management.
So, items I (Program Counter), II (Stack), and IV (Registers) are private to each individual thread.
Now looking at what they share: threads within the same process share the code section, data section, open files, heap, and the entire address space.
Therefore, only the address space (III) is shared by all threads in the process.
Looking at the options, this corresponds to III only.
Answer:
(A) III only
Ques 30 Gate 2017 Set-1
Consider the following CPU processes with arrival times (in milliseconds) and length of CPU bursts (in milliseconds) as given below:
| Process | Arrival Time | Brust Time |
|---|---|---|
| P1 | 0 | 7 |
| P2 | 3 | 3 |
| P3 | 5 | 5 |
| P4 | 6 | 2 |
If the pre-emptive shortest remaining time first scheduling algorithm is used to schedule the processes, then the average waiting time across all processes is _______ milliseconds.
Ques 31 Gate 2017 Set-1
Recall that Belady’s anomaly is that the pages-fault rate may increase as the number of allocated frames increases. Now consider the following statements:
S2: LRU page replacement algorithm suffer from Belady’s anomaly .
Which of the following is CORRECT?
Given:
Two statements regarding Belady's anomaly:
S1: Random page replacement algorithm suffers from Belady’s anomaly.
S2: LRU page replacement algorithm suffers from Belady’s anomaly.
To find:
Which of the statements S1 and S2 are correct.
Solution:
Let me check statement S2 first.
A page replacement algorithm is free from Belady's anomaly if it belongs to the class of stack algorithms.
For a stack algorithm, the set of pages in memory for n frames is always a subset of the pages in memory for n + 1 frames.
Since LRU (Least Recently Used) is a stack algorithm, it can never suffer from Belady's anomaly.
So, statement S2 is false.
Now let me check statement S1.
The Random page replacement algorithm randomly picks a page to replace.
Because of this random choice, it does not satisfy the inclusion property of stack algorithms.
Since it is not a stack algorithm, it can exhibit Belady's anomaly where increasing the number of frames leads to more page faults.
So, statement S1 is true.
Therefore, S1 is true and S2 is false.
Answer: (B) S1 is true, S2 is false
Ques 32 Gate 2017 Set-1
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:
PROCESSED
Ques 33 Gate 2017 Set-1
Threads of a process share
Ques 34 Gate 2016 Set-2
Consider a non-negative counting semaphore S. The operation P(S) decrements S, and V(S) increments S. During an execution, 20 P(S) operations and 12 V(S) operations are issued in some order. The largest initial value of S for which at least one P(S) operation will remain blocked is ________.
Ques 35 Gate 2016 Set-2
Consider the following processes, with the arrival time and the length of the CPU burst given in milliseconds. The scheduling algorithm used is preemptive shortest remaining-time first.
| Process | Arrival Time | Burst Time |
|---|---|---|
| P1 | 0 | 10 |
| P2 | 3 | 6 |
| P3 | 7 | 1 |
| P3 | 8 | 3 |
The average turn around time of these processes is ___________ milliseconds.
Ques 36 Gate 2016 Set-2
Consider the following two-process synchronization solution.
Process 0
---------
Entry: loop while (turn == 1);
(critical section)
Exit: turn = 1;
Process 1
----------
Entry: loop while (turn == 0);
(critical section)
Exit: turn = 0;
The shared variable turn is initialized to zero. Which one of the following is TRUE?
PROCESSED
Total Unique Visitors