0% found this document useful (0 votes)
40 views72 pages

OS 2022 Basic Questions Only

Uploaded by

sagnikmail2018
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views72 pages

OS 2022 Basic Questions Only

Uploaded by

sagnikmail2018
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 72

PROCESS & THREAD MANAGEMENT

Q1. [MSQ]
Which of the following is/are the functions of operating system?
(a) Sharing hardware among users and allowing users to share data among themselves.
(b) Recovering from errors.
(c) Preventing users from interfering with one another.
(d) Scheduling resources among users.

Q2. [MSQ]
Which of the following instructions is/are privileged (The Instructions that can run only
in Kernel Mode are called Privileged Instructions)?
(a) Set value of timer.
(b) Read the clock.
(c) Clear the Memory or Remove a process from the Memory.
(d) None of the above

Q3. [MSQ]
Which of the following instructions is/are privileged (The Instructions that can run only
in Kernel Mode are called Privileged Instructions)?
(a) Generate any trap instruction.
(b) Turn off all interrupts.
(c) Modify entries in device-status table.
(d) None of the above

Q4. [MSQ]
Which of the following instructions is/are privileged (The Instructions that can run only
in Kernel Mode are called Privileged Instructions)?
(a) Set the system clock.
(b) Read the system clock.
(c) Clear locations in virtual memory
(d) None of the above

BASIC OPERATING SYSTEM Page 1


Q5. [MSQ]
Which of the following instructions is/are privileged instructions (The Instructions that
can run only in Kernel Mode are called Privileged Instructions)?
(a) Instructions related to accessing I/O devices
(b) Switch from user to kernel mode.
(c) Switch from kernel to user mode.
(d) None of the above

Q6. [MSQ]
Which of the following instructions is/are privileged (The Instructions that can run only
in Kernel Mode are called Privileged Instructions)?
(a) Send a character to a printer
(b) Reading the status of Processor
(c) Write a value into the interrupt vector
(d) None of the above

Q7. Why separate user mode and kernel mode?


(a) So the OS cannot modify application’s data
(b) To prevent user applications from executing protected instructions
(c) It is a performance optimization
(d) None of the above
Q8. [MSQ]
Which of the following statements is/are true when the kernel switches execution from
the current process to another process?
(a) The kernel must save the register values (including IP (Instruction Pointer), SP (stack
pointer) etc.) of the current process to memory.
(b) The kernel must save the content of the current process’s memory on disk.
(c) The kernel must close all the files opened by the current process.
(d) The kernel must make the page table of the next process active.

BASIC OPERATING SYSTEM Page 2


Q9. [MSQ]
Which of the following statements is/are true about processes?
(a) Any process can access any other process’s memory by default.
(b) Timer interrupts are generally required for a kernel to correctly isolate processes.
(c) The kernel must run one process to completion before it starts another process.
(d) A user-level process can crash the kernel if not programmed carefully.
Q10. Which of the following does NOT happen when an interrupt occurs?
(a) The processor switches to privileged mode.
(b) The processors registers are saved so that they can be restored later.
(c) The processor jumps to an address that is found in the interrupt vector.
(d) The processor resets the automatic timer to a standard value.

Q11. An I/O-bound process _________.


(a) Spends equal time seeking I/O operations and doing computational work
(b) Spends more of its time doing computational work than seeking I/O operations
(c) Spends more of its time seeking I/O operations than doing computational work
(d) Spends less of its time seeking I/O operations than doing computational work

Q12. How did a time-sharing operating system differ from a batch operating system?
(a) The response time was slower on a time-sharing system.
(b) Security was simpler in time-sharing systems.
(c) Time-sharing systems allowed multiple processes to be running simultaneously.
(d) Compared to a batch system many of the scheduling decisions could no longer be
made by the operating system.

Q13. In the following process state transition diagram for a uni-processor system, which of the
arrows is/are invalid transition?

(a) 6 only (b) 4 and 6 only (c) 2, 4 and 5 only (d) 2, 4 and 6 only

BASIC OPERATING SYSTEM Page 3


Q14. Consider the following statements about process states and state transitions for a uni
processor system using preemptive scheduling:
1. A process state changes from NEW to READY when it is admitted to the system by
the long-term scheduler.
2. Process state changes from RUNNING to WAITING when its time slice expires.
3. Process state changes from WAITING to RUNNING when its I/O requirements
complete.
4. Only processes in the READY state can change into RUNNING state.
5. If a process is preempted, its state changes to READY.
6. There can be several processes in the READY state, but only one in the RUNNING
state
How many of the above statement(s) is/are TRUE?_____
Data for the next fourteen questions. Assume you have a system with three processes (X, Y and
Z) and a single CPU. Process X has the highest priority, process Z has the lowest, and Y is in the
middle. Assume a priority-based scheduler (i.e., the scheduler runs the highest priority job,
performing preemption as necessary). Processes can be in one of five states: RUNNING,
READY, BLOCKED, NEW (Not Yet Created), or TERMINATED. Given the following
cumulative timeline of process behaviour, indicate the state the specified process is in AFTER
that step, and all preceding steps, have taken place. Assume the scheduler has reacted to the
specified workload change. For all questions in this Part, specify the number of state for each
answer:
1. RUNNING
2. READY
3. BLOCKED
4. NEW
5. Not enough information to determine OR None of the above
Q15. Process X is loaded into memory and begins; it is the only user-level process in the
system. Process X is in which state? _____
Q16. Process X creates a new child process Y. Process X is in which state? _______

Q17. Process Y is in which state? ________

Q18. The running process issues an I/O request to the disk. Process X is in which state? ____

Q19. Process Y is in which state? _______

Q20. The running process creates a new child process Z. Process X is in which state? ______

BASIC OPERATING SYSTEM Page 4


Q21. Process Y is in which state? ______

Q22. Process Z is in which state? ______

Q23. The previously issued I/O request completes. Process X is in which state? _____

Q24. Process Y is in which state? ______

Q25. Process Z is in which state? ______

Q26. The running process completes. Process X is in which state? ______

Q27. Process Y is in which state? _____

Q28. Process Z is in which state? _____


Q29. Consider the following partial seven state process transition diagram for a uni-processor
system:

Which of the following transition is/are invalid for a uni-processor system?


(a) 8 and 9 only (b) 6, 9 and 5 only
(c) 3, 8 and 9 only (d) none of the mentioned
Q30. It is desirable to __________
(a) Minimize CPU utilization and throughput and to maximize turnaround time, waiting
time, and response time.
(b) Maximize CPU utilization and throughput and to minimize turnaround time, waiting
time, and response time.
(c) Maximize CPU utilization and turnaround time and to minimize throughput, waiting
time, and response time.
(d) Minimize waiting time and throughput and to maximize turnaround time, CPU
utilization, and response time.

BASIC OPERATING SYSTEM Page 5


Q31. Suppose that the operating system is running a non-preemptive scheduler and that process
P is currently running. A context switch can occur:
1. When P terminates.
2. When P blocks.
3. When another process unblocks.
4. When another process enters.
5. When the time quantum is exhausted.
6. When the priority of some other process exceeds the priority of P.
(a) 1, 2 only
(b) 3, 4 and 6 only
(c) 1, 2, 4 and 6 only
(d) All the above
Data for the next four questions. Consider the following CPU processes with arrival times and
length of CPU bursts as given below:
Processes Arrival Time CPU Burst Priority
P1 0 45 5 (lower)
P2 10 30 2
P3 10 15 1 (higher)

P4 80 60 4

P5 85 45 3
Q32. If the CPU scheduling policy is first come first sever, the average turnaround time will
be__________

Q33. If the CPU scheduling policy is round robin with time quantum of 15, the average waiting
time will be__________

Q34. If the CPU scheduling policy is shortest remaining time first, the average waiting time
will be_________

Q35. If the CPU scheduling policy is priority scheduling with preemption, the average
response time will be________

BASIC OPERATING SYSTEM Page 6


Data For the next seven questions. Consider five processes P1, P2, P3, P4 and P5 arrived in this
order at the same time with the following CPU burst and priority values. A smaller value means
a higher priority.
Process CPU Burst Time Priority
P1 4 2
P2 6 4
P3 2 1
P4 5 3
P5 3 5
Q36. Using FCFS, what is the CPU utilization in %?
(a)100 (b) 75 (c) 50 (d) 25
Q37. Using FCFS, What is the throughput?
(a) 0.50 (b)0.75 (c)0.25 (d)0.125

Q38. Using FCFS what is the average turnaround time for the processes?
(a)12.4 (b)11.8 (c)12.6 (d)12.2

Q39. Using SJF, what is the average turnaround time for the processes?
(a)10.2 (b)10 (c)10.4 (d)10.8

Q40. Using SRTF, what is the average turnaround time for the processes?
(a)10 (b)9.8 (c)9.6 (d)9.4

Q41. Using non preemptive priority scheduling, what is the average turnaround time for the
processes?
(a)11 (b)11.2 (c)11.1 (d)10.9

Q42. Using preemptive priority scheduling, what is the average turnaround time for the
processes?
(a)11 (b)11.2 (c)11.1 (d)10.9

BASIC OPERATING SYSTEM Page 7


Data for the next two questions. Assume you have been given the following jobs with the
indicated arrival and service times:
Job name Arrival time Service time
A 0 3
B 2 5
C 4 2
D 6 1
E 8 4
Q43. In what order, would these jobs run if the scheduling algorithm were first come first
serve?
(a) E,D,C,B,A
(b) D,C,A,E,B
(c) A,B,C,D,E
(d) A,E,B,D,C

Q44. In what order, would these jobs run if the scheduling algorithm were shortest job next?
(a)A,B,C,E,D,
(b)A,C,B,D,E
(c)A,B,C,D,E
(d)A,B,D,C,E

Q45. Consider the following set of processes, with the arrival times and the CPU burst times
given in milliseconds.
Processes Arrival-Time Burst-Time

P1 0 5

P2 1 3

P3 2 3

P4 4 1
What is the average turnaround time for these processes with the preemptive shortest
remaining time first (SRTF) algorithm?
(a) 5.75 (b) 5.50
(c) 6.00 (d) 6.25

BASIC OPERATING SYSTEM Page 8


Q46. Consider the following table of arrival time and burst time for three processes P0, P1 and
P2.
Processes Arrival Time Burst Time

P0 0 ms 9ms

P1 1 ms 4ms

P2 2 ms 9ms
The pre-emptive shortest job first scheduling algorithm is used. Scheduling is carried out
only at arrival or completion of processes. What is the average waiting time for the three
processes?
(a) 5.0 ms
(b) 4.33 ms
(c) 6.33 ms
(d) 7.33 m

Q47. Consider the following set of processes, the length of the CPU burst time given in
milliseconds:
Process Burst Time
P1 6
P2 3
P3 1
P4 7
Assuming the above process being scheduled with the Round-Robin scheduling
algorithm. Which of the following is not true about the average turnaround time?
(a) If the time quantum is 1, then the average turnaround time is 11.
(b) If the time quantum is 2, then the average turnaround time is 11.5.
(c) If the time quantum is 3, then the average turnaround time is 10.75.
(d) If the time quantum is 5, then the average turnaround time is 10.5.

BASIC OPERATING SYSTEM Page 9


Q48. Consider the following set of processes, the length of the CPU burst time given in
milliseconds (ms).
Process Burst Time
P1 6
P2 8
P3 7
P4 3
Assuming the above process being scheduled with the SJF scheduling algorithm. Which
of the following is not true?
(a) The waiting time for process P1 is 3ms.
(b) The waiting time for process P2 is 15ms.
(c) The waiting time for process P4 is 0ms.
(d) The waiting time for process P3 is 9ms.
Q49. [MSQ]
Assume the OS schedules a workload containing three jobs with the following
characteristics:

Job Arrival Time CPU burst


A 0 10
B 5 8
C 12 2
Which scheduler minimizes the completion time of the entire workload?
(a) SRTF (b) RR (c) SJF (d) FCFS
Q50. Consider the following 3 processes, and lower number has higher priority
Process Arrival Time CPU Burst Time Priority
P1 0 5 3
P2 2 4 1
P3 4 6 2
Using non preemptive priority scheduling, What is the average waiting time for the
processes?__________
Q51. Consider the following four processes and lower number has higher priority
Process Arrival time CPU Burst Priority
P1 1 5 4
P2 0 6 2
P3 3 3 1
P4 2 7 3
Using preemptive priority scheduling what the average waiting time for the
processes?____________

BASIC OPERATING SYSTEM Page 10


Data for the next two question. Consider the following 5 processes, smaller the number denote
a higher priority
Processes Arrival Time CPU Time Priority
P1 0 10 5
P2 0 7 2
P3 4 5 1
P4 10 15 4
P5 20 3 3
Q52. What is the average response time using non-preemptive priority scheduling?_____
Q53. What is the average response time using preemptive priority scheduling? ____
Q54. Consider a set of 5 processes whose arrival time and CPU Burst time is given as follow:
Process Arrival Time (in ms) CPU Burst(in ms)
P1 0 10
P2 0 5
P3 2 3
P4 5 20
P5 10 2
Using FCFS Scheduling, what is the CPU Utilization (in percentage), when context
switching time between the process is 0.001 sec?________
Q55. Consider the following 5 processes with their arrival and CPU Burst time:
Process Arrival Time (in ms) CPU Burst (in ms)
P1 1 10
P2 0 5
P3 2 3
P4 1 20
P5 7 2
If the CPU scheduling policy is SJF and context switching time between the processes is
0.01 sec, What is the CPU Utilization (in percentage)? _______

Q56. Consider three CPU-intensive processes, which require 10, 20 and 30 time units and
arrive at times 0, 2 and 6, respectively. How many context switches are needed if the
operating system implements a round robin scheduling algorithm with time quantum of
4? Do not count the context switches at time zero and at the end.__________

BASIC OPERATING SYSTEM Page 11


Q57. Consider the processes P1, P2, P3, P4 whose arrival times are 0 and Burst times are 5, 2,
13, 3. If the context switching time is 0 unit (ms) and the first context switch is not
considered, what is the average turnaround time if First Come First Serve scheduling
algorithm is used? ___________
Q58. Consider the processes P1, P2, P3, P4 whose arrival times are 0, 1, 2, 3 and Burst times are
5, 2, 13, 3. If the context switching time is 1 unit (ms) and the first context switch is not
considered, what is the average waiting time if Shortest Job First scheduling algorithm is
used? __________
Q59. Consider the processes P1, P2, P3, P4 whose arrival times are 0, 1, 2, 3 and Burst times are
5, 2, 13, 3. If the context switching time is 1 unit (ms) and the first context switch is not
considered, what is the average waiting time if Shortest Remaining Time First scheduling
algorithm is used? ___________
Q60. Consider 3 processes that start simultaneously. Each process from start to finish takes 40,
50, and 60 ms respectively. Of this, the first 20% of the time is spent waiting for I/0 events
and the next 80% time for computation. The scheduler uses FCFS scheduling. Assuming
that all I/O operations are overlapped. How much time in milliseconds is the CPU idle?
____________
Q61. Consider three processes, all arriving at time zero, with total execution time of 20, 30 and
40 units, respectively. Each process spends the first 10% of execution time doing I/O, the
next 70% of time doing computation, and the last 20% of time doing I/O again. The
operating system uses a shortest remaining time first scheduling algorithm. Assume that
all I/O operations can be overlapped as much as possible. For what percentage of time
does the CPU remain idle?__________(Round of two three decimal place)
Q62. Consider the following two processes:
 P1, arriving at time t= 0, completing after two CPU bursts of 10ms each separated by
a single I/O burst of 15ms.
 P2, arriving at time t= 2, completing after three CPU bursts of 5ms each separated by
two I/O bursts of 10ms each.
Assume that there is no context switch overhead and I/O can be overlapped as much as
possible. What is the total waiting time for each of the two processes assuming SRTF
scheduling?
(a)P1=10,P2=10 (b) P1=10,P2=0
(c) P1=0,P2=10 (d) P1=20,P2=10

BASIC OPERATING SYSTEM Page 12


Q63. Three processes P1, P2 and P3 each execute a loop of 2 iterations. In each iteration of the
loop, a process performs a single computation that requires TCPU milliseconds and then
initiates a single I/O operation that lasts for TI/O milliseconds. The I/O operation of
processes can be overlapped with CPU operation as much as possible. The processes have
the following characteristics:
Processes Arrival Time (in ms) TCPU (in ms) TI/O (in ms)
P1 0 100 500
P2 10 300 500
P3 20 250 500
The operating system use round robin scheduling with a time slice of 50 milliseconds.
The average waiting time of all process in milliseconds is ___________.

Q64. Consider a system where there are 3 processes, A, B, and C. Their details are as follows
Burst Time
Processes Arrival Time
CPU IO CPU IO CPU
A 0 3 4 2 6 6
B 2 2 5 4 5 4
C 4 5 2 3 3 5
Assume that I/O can be overlapped as much as possible. What is the completion time for
C with FCFS scheduling?
(a) 34 (b)35
(c)36 (d)37

Q65. The performance of Round Robin algorithm depends heavily on


(a) The size of the process.
(b) The I/O bursts of the process.
(c) The CPU bursts of the process.
(d) The size of the time quantum.

BASIC OPERATING SYSTEM Page 13


Q66. [MSQ]
Which one of the following is/are true for fixed number of process if the Shortest Job
First scheduling is used?
(a) Minimizes average waiting time and minimizes turnaround time.
(b) Exhibits the convoy effect.
(c) Minimizes CPU throughput.
(d) Can be approximated with Round Robin scheduling with a long time slice quantum.

Q67. An SJF algorithm is simply a priority algorithm where the priority is :


(a) The predicted next CPU burst (b) The inverse of the predicted next CPU burst
(c) The current CPU burst (d) Anything the user wants

Q68. If we have only one process in ready queue with burst time "m", then how many context
switching will happen using round robin scheduling with time quantum q, where q<m.
Assume that dispatching the process first time is not counted as a context switch.
(a) 1 (b) (m/q) – 1 (c) 0 (d) m/q

Q69. [MSQ]
Which of the following is/are true:
(i) Starvation could occur on an OS with non-preemptive scheduling
(ii) Starvation could occur on an OS with preemptive scheduling
(iii) Deadlock could occur on an OS with non-preemptive scheduling
(iv) Deadlock could occur on an OS with preemptive scheduling

Q70. Which of these is a disadvantage of First Come First Serve?


(a) Convoy Effect (b) Small average and worst-case waiting times
(c) Simplicity (d) Non-preemptive

Q71. Process waiting time is given with the probability p. There are n processes in the memory
then the CPU utilization is given by,
(a) p/n (b) pn (c)1-pn (d) n-(pn)

BASIC OPERATING SYSTEM Page 14


Q72. Suppose a new process in a system arrives at an average of six processes per minute and
each such process requires an average of 8 seconds of service time. Estimate the percent
of time the CPU is busy in a system with a single processor.________

Q73. The next CPU burst of the newly arrived process may be shorter than what is left of the
currently executing process. A______will preempt the currently executing process
(a) preemptive priority scheduling algorithm
(b) non-preemptive SJF algorithm
(c) preemptive SJF algorithm
(d) First-Come, First-Served Scheduling

Q74. Consider the following preemptive priority-scheduling algorithm based on dynamically


changing priorities. Larger priority numbers imply higher priority. When a process is
waiting for the CPU (in the ready queue but not running), its priority changes at a rate X
when it is running, its priority changes at a rate Y. All processes are given a priority of 0
when they enter the ready queue. The parameters and can be set to give many different
scheduling algorithms. What is the algorithm that results from Y>X>0?
(a) LIFO (b) FCFS
(c) Round Robin (d) None of the above

Q75. In Round-Robin scheduling algorithm, If the CPU burst of the currently running process
is longer than 1 time quantum. In this case:
(a) The timer will go off and will cause an interrupt to the operating system. A context
switch will be executed, and the process will be put at the rear of the ready queue, The
CPU scheduler will then select the next process in the ready queue.
(b) the timer will go off and will cause an interrupt to the operating system. A context
switch will be executed, and the process will be put at the front of the ready queue, The
CPU scheduler will then select the next process in the ready queue
(c) the process itself will release the CPU voluntarily. The scheduler will then proceed to
the next process in the ready queue
(d) the process itself will not release the CPU voluntarily. The scheduler will then proceed
to the next process in the ready queue

BASIC OPERATING SYSTEM Page 15


Q76. [MSQ]
Which of the following statement is/are TRUE?
(a) In priority scheduling, I/O-bound processes should be given a higher priority than
CPU-bound processes in order to make more efficient use of the CPU.
(b) A short quantum in a round-robin scheduler gives better response time for interactive
users but less efficient use of the CPU than a longer quantum
(c) If all jobs have identical run lengths, a RR scheduler (with a time-slice much shorter
than the jobs’ run lengths) provides better average turnaround time than FIFO.
(d) The longer the time slice, the more a RR scheduler gives similar results to a FIFO
scheduler.

Q77. [MSQ]
Which of the following statements is always not true about the multilevel feedback queue
Scheduling.
(a) It has better response time than SJF
(b) Like SJF, the starvation is a possible problem.
(c) The short interactive jobs tend to have shorter waiting time than the batch jobs.
(d) It is a combination of priority scheduling and round robin scheduling with different
quantum.

Q78. [MSQ]
Which of the following statement is/are True for Aging
(a) Aging involves gradually increasing the priority of processes that wait in the system
for a long time
(b) Aging involves gradually decreasing the priority of processes that wait in the system
for a long time
(c) Aging involves gradually increasing the priority of processes that wait in the system
for a small time
(d) Aging involves gradually decreasing the priority of processes that wait in the system
for a small time

BASIC OPERATING SYSTEM Page 16


Q79. Which of the following scheduling algorithms will tend to schedule I/O bound jobs
Before CPU bound jobs?
(a)Shortest-time-to-completion-first (b) Multilevel Feedback Queues
(c) Round Robin (d) First Come First Serve.

Q80. Consider an OS with MLFQ scheduling algorithm, the scheduler supports multiple
queues with different priorities. Each queue use Round Robin scheduling, running the
jobs in highest priority queue first (a lower number queue has higher priority), Once
process finish its time quanta, scheduler place the process into the next highest priority
queue, Round robin time slice increases exponentially at lower priorities. A process
scheduled from RQ0 is allowed to execute for one time unit and then is preempted; a
process scheduled from RQ1 is allowed to execute two time units, and so on. In general,
a process scheduled from RQi is allowed to execute 2i time units before preemption. When
a process moves from one queue to next higher queue, it is added to the end of the queue.
Process Arrival Time CPU Burst Time
A 0 3
B 2 6
C 4 4
D 6 5
E 8 2
Assume that all processes arrived in the highest priority queue, and that the scheduler
will run the process at the head of queue. Assume processes spent at most 2i time unit in
RQi queue either it execute partially or continuously. What is the Average Turnaround
Time for the all process? ______________
Q81. When a process creates a new process, which of the following happens?
(a) A child can execute only after its parent has terminated.
(b) The parent continues to execute concurrently with its children.
(c) The parent can execute only after all its children have executed and terminated.
(d) Either (a) or (c)

Q82. When a process is created using the classical fork() system call, which of the following is
not inherited by the child process?
(a) process address space (b) process ID
(c) user ID (d) open files

BASIC OPERATING SYSTEM Page 17


Q83. Which one of the following is a reason for which a parent process may terminate the
execution of one of its children processes:
(a) The child has exceeded its usage of some of the resources allocated to it.
(b) The tasks assigned to the child is no longer required.
(c) The parent is exiting, and the operating system does not allow a child to continue if
its parent terminates.
(d) Any of the above

Q84. In operating system, the fork() system call returns


(a) A value of -1 to the parent process if no child process is created.
(b) The process ID of the child process to the parent process.
(c) A value of 0 to the child process.
(d) All of the above

Q85. [MSQ]
Which statements is/are TRUE about fork ()?
(a) It creates a child process which can share the global variables of parent process.
(b) It creates a child process which shares the address space of the parent process.
(c) It creates a child process which cannot be terminated till parent is terminated.
(d) Child process is automatically terminated if parent is terminated.
(e) fork () returns PID of parent to child and PID of child to parent.

Q86. How many times does the following program print “Hello World”?_______________
#include<stdio.h>
#include<unistd.h>
int main()
{
int i;
for (i = 0; i < 3; i++){ fork();}
printf("Hello World\n");
return 0;
}

BASIC OPERATING SYSTEM Page 18


Q87. A process executes the following segment of code:
#include<stdio.h>
#include <unistd.h>
int main()
{
fork();
fork() && fork();
return 0;
}
The number of new processes created is __________
Q88. A process executes the following segment of code:
#include<stdio.h>
#include <unistd.h>
int main()
{
if (fork() || fork())
fork();
return 0;
}
The number of new processes created is __________
Q89. Consider the following code.
#include<stdio.h>
#include <unistd.h>
int main() {
int count = 0;
if(fork()) { count++; }
if(fork()) { count++; }
printf("%d \n", count);
return 0;
}
How many total (including main process) different processes will be created by the above
program?
(a)6 (b)5
(c)3 (d)4

BASIC OPERATING SYSTEM Page 19


Q90. Consider this program:
#include<stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main() {
fork();
int pid = fork();
if (pid == 0) { fork();}
exit();
}
How many processes are created when we execute this program, including the first
process created by shell?
(a) 2 (b) 4
(c) 6 (d) 8
Q91. How many times does the following program print “Hello World”?
#include<stdio.h>
#include <unistd.h>
int main()
{
int i;
for (i = 0; i < 3; i++) fork();
printf("Hello World\n");
return 0;
}
(a)7
(b)15
(c)31
(d)3

BASIC OPERATING SYSTEM Page 20


Q92. Consider the following example program. The output consists of strings made up of
multiple letters.
#include<stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main()
{
printf("A");
int child = fork();
printf("B");
if (child) wait(NULL);
printf("c");
return 0;
}
How many of the legal outputs this program may produce when executed on a
system?____________

Q93. Consider this program:


#include<stdio.h>
#include <unistd.h>
int main() {
fork();
int pid = fork();
if (pid == 0)
exec("/bin/ls"); // It does NOT create any process
else
fork();
return 0;
}
How many processes are created when we execute this program, including the parent
process? ______________

BASIC OPERATING SYSTEM Page 21


Q94. Consider the following code snippet (you may assume that fork() never fails)
#include<stdio.h>
#include <unistd.h>
int main() {
if ((p1_pid = fork())== 0){
printf(“I am P1 ”);
}
else {
if ((p2_pid = fork()) == 0) {
p3_pid == fork();
printf(“I am P3.”);
p4_pid == fork();
printf(“I am P4.”);
}
else
printf(“I am the parent process”);
return 0;
}
How many processes (excluding the parent) will be created?__________
Q95. Consider the following code snippet (you may assume that fork() never fails)
#include<stdio.h>
#include <unistd.h>
int main()
{
for (int i=0; i<2; i++) {
if (fork()) {
printf("%d", i);
} else {
printf("%d", 3-i);
}
}
return 0;
}
How many different values printed by the above code?____________

BASIC OPERATING SYSTEM Page 22


Q96. Consider the following code snippet (you may assume that fork() never fails)
#include<stdio.h>
#include <unistd.h>
int main() {
if (fork()) {
printf("0");
wait(NULL);
printf("1");
} else {
if (fork()) {
printf("2");
wait(NULL);
printf("3");
} else {
printf("4");
}
}
}
How many different combination of output printed by the above code?____________
Q97. [MSQ]
A thread is usually defined as a “light weight process” because an operating system (OS)
maintains smaller data structures for a thread than for a process. In relation to this, which
of the following is/are TRUE?
(a) On per-thread basis, the OS maintains only CPU register state
(b) The OS does not maintain a separate stack for each thread
(c) On per-thread basis, the OS does not maintain virtual memory state
(d) On per-thread basis, the OS maintains only scheduling and accounting information

Q98. [MSQ]
Which of the following is/are FALSE statements?
(a) The code that changes the system clock runs in user mode.
(b) Without kernel-level support, when a user-level thread blocks, it will block all the
other threads in the same process.
(c) Context switching between two kernel threads has about the same overhead as that
between two user processes.
(d) A thread can be blocked on multiple condition variables simultaneously.

BASIC OPERATING SYSTEM Page 23


Q99. [MSQ]
Which of the following is/are correct about threads of any process?
(a) Compared to a process, switching between threads of same process takes less time as
quantum allotted for threads is less.
(b) Threads of a process share same address space.
(c) Intra-thread communication is faster as the threads of one process share address
space.
(d) Compared to a process, switching between threads of same process takes less time as
next-to-run thread shares same address space.
Q100. For threads belonging to same process, which of the following resources is not shared
among these threads?
(a) Stack (b) Code
(c) Data (d) File Handles

Q101. [MSQ]
Which of the following statements regarding threads is/are true?
(a) Threads are cheaper to create than processes.
(b) All kernel-scheduled threads of a process share the same virtual address space.
(c) Threads are cheaper to context switch than processes.
(d) None of the above

Q102. [MSQ]
Which of the following statements regarding threads is/are true?
(a) Kernel-scheduled threads are cheaper to create than user-level threads.
(b) A blocking kernel-scheduled thread blocks all threads in the process.
(c) Different user-level threads of the same process can have different scheduling
priorities.
(d) None of the above
Q103. A thread shares its resources (like data section, code section, open files, signals) with:
(a) Other process similar to the one that the thread belongs to
(b) Other threads that belong to similar processes
(c) Other threads that belong to the same process
(d) All of the above

BASIC OPERATING SYSTEM Page 24


Q104. Because the kernel thread management is done by the Operating System itself ________
(a) kernel threads are faster to create than user threads
(b) kernel threads are slower to create than user threads
(c) kernel threads are easier to manage as well as create then user threads
(d) none of the mentioned
Q105. [MSQ]
Which of the following statements is/are true?
(a) A process may contain multiple threads, but each thread belongs to only one process
(b) Kernel-level threads of the same process do not share the same memory address
space.
(c) User-level threads of the same process share the same memory address space.
(d) None of the above

Q106. In a 1:1 threading model, what happens to the other threads when one thread makes a
blocking system call?
(a)They may be scheduled
(b) All the other threads will blocked
(c) It’s depend on operating system
(d) can’t say anything

Q107. [MSQ]
Which of the following statements regarding threads is/are true?
(a) In many-to-many model, you can map a user-level thread to more than one
lightweight process, which allows the thread to continue even if a blocking call was
made to one of the kernel threads (mapped to the user-level thread).
(b) In many-to-one model, we have multiple user-level threads mapped to one kernel-
level thread. When a user-level thread makes a blocking system call, the entire process
blocks.
(c) In one-to-one model, we have one user-level threads mapped to one kernel-level
thread. When a user-level thread makes a blocking system call, the entire process
blocks.
(d) None of the above

BASIC OPERATING SYSTEM Page 25


Data for the next two questions. Suppose that two long running processes, P1 and P2, are
running in a system. Neither program performs any system calls that might cause it to block,
nor there other processes in the system. P1 has 2 threads and P2 has 1 thread.
Q108. What percentage of CPU time will P1 get if the threads are kernel threads? ________

Q109. What percentage of CPU time will P1 get if the threads are user threads? __________

BASIC OPERATING SYSTEM Page 26


PROCESS SYNCHRONIZATION AND DEADLOCK
Q1. [MSQ]
Consider the following two processes A and B, where initially value of integer x = 0:
Process A Process B
main() main()
{ {
int i; int i;
i = x; i = x;
i = i + 2; i = i - 1;
x = i; x = i;
} }
Which of the following values x cannot take after the two processes have completed?
(a) -1 (b) 0 (c) 1 (d) 2
Q2. Consider the following two processes A and B, where initially int x = 0:
Process A() Process B()
{ {
int i; int i;
i = x; i = x;
i = i + 2; i = i - 1;
x = i; x = i;
} }
What are the final values of x after both processes complete (give all possibilities)?
(i) 0 (ii) 1 (iii) 2 (iv) 3 (v) 4
(a) i and ii only (b) i, ii and iii only
(c) ii, iii and iv only (d) iii ,iv and v only

Q3. Consider the following two-thread program, where initially value of integer counter =
0:
Thread T Thread U
main() main()
{ {
int cnt; int cnt;
cnt = counter; cnt = counter;
cnt = cnt + 1; cnt = cnt + 1;
} print(cnt);
}
What do the above threads print?
(a) it’s always print 0
(b) It’s always print 1
(c) it sometimes print 0 and sometimes print 1
(d) it sometimes print 1 and sometimes print 2

BASIC OPERATING SYSTEM Page 27


Q4. Consider the following two processes A and B:
Process A Process B
main() main()
{ {
Count += 3; Count -= 5;
} }
Assuming that count was initially equal to 20, what value cannot it take after the two
processes have completed?
(a) 15 (b) 18 (c) 20 (d) 23

Q5. [MSQ]
Assume that s is the mutex semaphore. Which of the following order of statements
is/are deadlock or violation of mutual exclusion?(assume s=1)
1. Signal(s); critical_section(); Wait(s);
2. Wait(s); critical_section(); Signal(s);
3. critical_section(); Signal(s);
4. Wait(s); critical_section(); Wait(s);
5. Wait(s); Wait(s); critical_section(); Signal(s); Signal(s)
Q6. In a certain application, the initial value of a counting semaphore s is 10. The following
operations were completed on the semaphore in the given order 8P, 5V, 5V, 8P, 5V, 10P,
12V. The new value of counting semaphore s is ____________

Q7. Let S be the counting semaphore variable S = 5 initially. Assume that no blocked
processes exist in the system. The following signal (V), wait (P) operations are
performed: 4 P, 6 V, 9 P, 13 V, and 14 P. The numbers of blocked processes at the end
are _________.

Q8. In a certain application, the initial value of a counting semaphore S is 10. The following
operations were completed on the semaphore in the given order 5P, 20P, 2V, 18P, 5V,
10P, 1V. The new value of counting semaphore is ____________

Q9. What is value of binary semaphore "S" after executing 10 P (Wait) operations and 14 V
(Signal) operations if the initial value of "S" is 1?_________

BASIC OPERATING SYSTEM Page 28


Q10. Consider the following two-thread program, where initially value of mutex
semaphores s1 and s2 is 1:
Thread T Thread U
main() main()
{ {
wait(s1); wait(s1);
wait(s2); wait(s2);
print(T); print(U);
signal(s1); signal(s1);
signal(s2); signal(s2);
} }
What do the above threads print?
(a) It print T followed by U
(b) It print U followed by T
(c) Either of the answer above
(d) Either of the answer above or it does not print anything.
Q11. What is the value of n after 10 concurrent threads terminate, where initially value of
counting semaphore s = 2 and n=0?
Thread Tk
int x;
wait(s);
x = n;
n = x + 1;
signal(s);
(a) Between 1 and 10 (b) Between 5 and 10
(c) Always 5 (d) Always 10

Q12. Consider the program below, with the three binary semaphores:
Binary semaphore SA = 0, SB = 0, SC =
1;
Process A Process B Process C
While(1) While(1) While(1)
{ { {
wait(SB); wait(SC); wait(SA);
print(A); print(B); print(C);
signal(SC); signal(SA); signal(SB);
} } }
What does the program print?
(a) ABCABCABC… (b) BACBACBAC…
(c) BCABACBCA… (d) BCABCABCA…

BASIC OPERATING SYSTEM Page 29


Data for the next three questions. Consider that following concurrent process running on a
system using following counting semaphore U = 3 and V = 0;
[Process1] [Process 2] [Process 3]
L1:wait (U) L2:wait(V) L3: wait(V)
type("C") type("A") type("D")
signal(V) type("B") goto L3
goto L1 signal(V)
goto L2
Q13. How many C’s are printed when the set of these processes runs?
(a) 3 (b) 4 (c) 5 (d) 6

Q14. What is the maximum number of times D’s get printed when the set of these processes
runs?
(a) 3 (b) 4 (c) 5 (d) 6

Q15. What is the minimum number of time that A might be printed?


(a) 0 (b) 1 (c) 3 (d) 4
Q16. A process P tries to acquire a lock using the atomic Test_and_Set instruction:
while (Test_and_Set(lock)) do no-op;
If the lock is busy (some other process has acquired it) and all interrupts are disabled,
then
(a) Process P blocks, waiting for the lock to be available
(b) Process P wastes processor and memory cycles
(c) Process P will continue its execution.
(b) None of the above

Q17. [MSQ]
Consider that following three concurrent process P1, P2 and P3 are running on the
system. int count = 10;
Semaphore Lock = 1; // initial value is 1
P1 P2 P3
{ { {
// do something // do something // do something
wait(lock); wait(lock); wait(lock);
count++; count−−; printf(‘‘%d’’, count);
signal(lock); signal(lock); signal(lock);
} } }
What are the possible outputs of this program when all three processes terminated?
(a) 9 (b) 10 (c) 11 (d) 12

BASIC OPERATING SYSTEM Page 30


Q18. Consider that following concurrent process running on a system Using following
binary semaphore ,Semaphore X = 1, Y = 0, Z = 0
Which of the following is the possible output after all four processes terminated?
Thread 1 Thread 2 Thread 3 Thread 4
wait(X) wait(Z) wait(Y) wait(Y)
print "4" wait(Y) print "2" wait(X)
signal(Z) print "3" signal(X) print "1"
signal(Y) signal(Y) signal(Z) wait(Z)
signal(Y) print"5"
(a) 42315
(b) 43215
(c) 43152
(d) 42153
Q19. Consider the following three concurrent process
Three processes p1; p2; p3;
semaphores s1 = 1, s2 = 0;
p1 p2 p3
while(true) while(true) while(true)
{ { {

wait(s1); wait(s2); wait(s2);


A B C
up(s2); up(s2); up(s1);
} } }
Which execution orders of A, B, C, are possible?
(a)(AB*C)* (b) (AB*C)+
(c) (AC)+B* (d) (ACB)+
Data for the next two questions. Given the following routine:
process P1 {
print (1 ) ; print ( 2 ) ;
}
process P2 {
print ( 3 ) ; print (4) ;
}
process P3 {
print ( 5 ) ; print ( 6 ) ;
}
Q20. How many different outputs could this program produce?______
Q21. How many semaphores to the program need to add so that the six lines of output are
printed in the order: 1, 2, 3, 4, 5, 6.
(a)1 (b) 2 (c) 3 (d) 4

BASIC OPERATING SYSTEM Page 31


Q22. Consider the following code to ensure mutual exclusion between two processes P0 and
P1, pid of P0 is 0 and that of P1 is 1 where initially int turn = 0
process pi
{
while (turn = = (1-pid));
CS
Turn=(1-pid)
}
The above solution ensures
1. Mutual exclusion 2. Bounded wait 3. Progress
(a) 1 only (b) 1 and 2 only
(c) 2 and 3 only (d) Only 1 and 3
Q23. Consider the following code to ensure mutual exclusion between two processes P0 and
P1, pid of P0 is 0 and that of P1 is 1, where initially int turn = 0 and int lock[2] ={0,0}:
Process Pi
{
lock[pid]=1;
turn=1-pid;
while(lock[1-pid]&&turn
= = (1-pid));
CS
lock[pid]=0;
}
The above solution ensures
1. Mutual exclusion 2. Bounded wait 3. Progress
(a) 1 only (b) 1 and 2 only
(c) 2 and 3 only (d) Only 1, 2 and 3

Q24. [MSQ]
Consider the following two process solution to critical section problem
Boolean flag[2] ={FALSE , FALSE}
Process Pi
do {
while (flag[j]);
flag[i] = TRUE;
critical section
flag [i] = FALSE;
remainder section
} while (TRUE);
Which of the following solution is/are satisfied.
(a) Mutual exclusion (b) Bounded wait
(c) Progress (d) None of these

BASIC OPERATING SYSTEM Page 32


Q25. [MSQ]
Consider the following two process solution to critical section problem:
Boolean flag[2] ={FALSE , FALSE}
Process Pi
do {
flag[i] = TRUE
while (flag[j]);
critical section
flag [i] = FALSE;
remainder section
} while (TRUE);
Which of the following solution is/are satisfied?
(a) Mutual exclusion
(b) Bounded wait
(c) Progress
(d) None of these

Q26. The following algorithm is used to synchronize two processes.


Shared Variables :
Shared Variables :
Boolean flag[2];
flag[0] = flag[1] = false.

Process Pi
do {
flag[i] = true;
While (flag[j]);
Critical section
flag [i] = false;
remainder section
}while (1)
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

BASIC OPERATING SYSTEM Page 33


Q27. The wait(P) and signal(V) operations on counting semaphores C, are defined as
follows:
P(C): C = C – 1; V(C): C = C + 1;
if (C < 0) then if (C<= 0) then wakeup a process waiting
wait; on C;
Assume that wait (Pb) and signal (Vb) the operations on binary semaphores are
provided. Three binary semaphores S1 , S2 and S3 are used to implement the semaphore
operations P(S) and V(S) as follows:
wait(S): signal(S):
wait (S3); wait (S1);
wait (S1); C=C+1;
C = C-1; If(C<=0){
If(C<0){ signal(s2)
signal(S1); }
wait(S2); signal(S1);
} else
Signal (S1)
}
Signal (S3)
What should be the initial value of Semaphore S1, S2 and S3?
(a)S1= S3= 1 and S2=0
(b) S1= S3= 1 and S2=1
(c)S1=S2=0 and S3= 1
(d)S1= S3= 0 and S2=1
Q28. Consider the following algorithm that provides a solution to the two process critical
section problem.
Initially flag[0] = false; flag[1] = false;
P0; P1;
while (true) while (true)
{ {
Flag[0]=true; Flag[1]=true;
while (flag[1]) while (flag[0])
{ {
flag[0]=false; flag[1]=false;
while(flag[1]); while(flag[1];
flag[0]=true; flag[1]=true;
} }
critical section critical section
flag[0]=false; flag[1]=false;
} }
The above solution ensures
1. Mutual exclusion 2. Bounded wait 3. Progress
(a) 1 only (b) 3 only (c) 1 and 3 only (d) 1, 2 and 3 only

BASIC OPERATING SYSTEM Page 34


Q29. Consider the following algorithm that provides a solution to the 2 process critical
section problem.
Initially Boolean C1 = false, C2 = false; integer Turn = 1;
P1; P2;
while (1) while (1)
{ {
C1=true; C2=true;
If(~C2)then If(~C1)then
Turn=2; Turn=1;
while(Turn==1); while(Turn==2);
critical section; critical section;
Turn=1; Turn=2;
C1=false; C1=false;
} }
The above solution ensures
1. Mutual exclusion
2. Bounded wait
3. Progress
(a) 1 only (b) 2 only
(c) 1 and 2 only (d) 2 and 3 only
Q30. Consider the following solution for the two process mutual exclusion problem:
boolean flag[2] = {FALSE, FALSE};
int turn = 0;
Process Pi {
int j = 1 – i;
while (1) {
flag[i] = TRUE;
turn = i;
while (flag[j] && (turn == j));
[critical section]
flag[i] = FALSE;
}
}
Which of the following condition is/are ensure by above solution?
(a) Mutual exclusion
(b) Bounded wait
(c) Progress
(d) None of these

BASIC OPERATING SYSTEM Page 35


Q31. The atomic_add 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 pseudo code shown below to implement a busy-wait lock. Lock is an unsigned
integer shared variable initialized to 0. The value of 0 corresponds to lock being
available, while any non-zero value corresponds to the lock being not available.
struct Lock {int locked;}

void acquire(Lock *l) {


while (1) {
if (atomic_add(&l->locked, 1) == 1) { break; }
l->locked--;
}
}

void release(Lock *l) { l->locked--; }


This implementation
(a) fails as lock can overflow
(b) fails as lock 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
Q32. Barrier is a synchronization construct where a set of processes synchronizes globally i.e.
each process in the set arrives at the barrier and waits for all others to arrive and then
all processes leave the barrier. Each of a set of n processes executes the following code
using two semaphores a andb initialized to 1 and 0, respectively. Assume that count is a
shared variable initialized to 0 and not used in meeting point code.
Meeting point
<Barrier Code>
Critical point
The synchronization requirement is that no process executes critical point until all
process has executed meeting point. When the first n − 1 processes arrive they should
block until the nthprocess arrives, at which point all the processes may proceed. Which
of the following code correctly implements the barrier code?
(a) (b)
wait(a); count = count + 1 wait(a); count = count + 1
signal(a); signal(a);
if (count == if (count == n) signal(b);
n)signal(b);wait(b); wait(b); signal(b);

(c) (d)
wait(a);count = count + 1 wait(a); count=count+1;
if (count == n) signal(b); if (count==n) signal (b);
wait(b); signal(b); signal (a); wait (b);
signal(a) signal (b);

BASIC OPERATING SYSTEM Page 36


Q33. Barrier is a synchronization construct where a set of processes synchronizes globally
i.e., each process in the set arrives at the barrier and waits for all others to arrive and
then all processes leave the barrier. Let the number of processes in the set be n and S be
a binary semaphore with the usual P and V functions. Consider the following C
implementation of a barrier with line numbers shown below.
void barrier (void) {
P(S);
process_arrived++;
V(S);
while (process_arrived !=n);
P(S);
process_left++;
if (process_left==n) {
process_arrived = 0;
process_left = 0;
}
V(S);
}
The variables process_arrived and process_left are shared among all processes and
are initialized to zero. In a concurrent program all the three processes call the
barrier function when they need to synchronize globally. The above implementation of
barrier is incorrect. Which one of the following is true?
(a) The barrier implementation is wrong due to the use of binary semaphore S.
(b) The barrier implementation may lead to a deadlock if two barrier in invocations are
used in immediate succession.
(c) The barrier implementation is correct if there are only n-1 processes instead of n.
(d) The barrier implementation is correct for the set of n processes
Q34. Consider the following solution to the producer-consumer synchronization problem
with bounded buffer of size N.
Initialization:
Semaphore empty = 0, full = N, mutex = 1;
Producer: Consumer:
do { do {
wait (P); wait (R);
wait (mutex); wait (mutex);
//Add item to buffer //consume item from buffer
signal (mutex); signal (mutex);
signal (Q); signal (S);
}while (1); }while (1);
The placeholder variables, denoted by P, Q, R and S, in the code above can be assigned
either empty or full. The valid semaphore operations are: wait() and signal().Which one
of the following assignments to P, Q, R and S will yield the correct solution?

BASIC OPERATING SYSTEM Page 37


(a) P:full, Q:full, R:empty, S:empty
(b) P:empty, Q:empty, R:full, S:full
(c) P:full, Q:empty, R:empty, S:full
(d) P:empty, Q:full, R:full, S:empty

Data for the next two questions. Consider the following code for accessing a shared - buffer that
contains very large number of elements (i.e. max). There is multiple producer consumer process
access this code concurrently. Assume the initial value of mutex is zero and that buffer is initially
empty. Assume the semaphore empty is initialized to max and fill is initialized to 0. (lock =0
means lock is available)
Producer() { Consumer() {
0. while(true) { 0. while(true) {
1. lock(mutex) // p1 1. lock(mutex) // c1
2. if (buffer == max) // p2 2. if (buffer == 0) // c2
3. wait(empty) // p3 3. wait(fill) // c3
4. do_fill(i) // p4 4. int tmp = do_get(); // c4
5. signal(fill) // p5 5. signal(empty); // c5
6. unlock(mutex) // p6 6. unlock(mutex); // c6
7. } 7. }
Q35. If a producer process P executes all the lines from P1 to P6. Then which line consumer
will not able to execute if it Scheduled after producer?
(a) c1
(b) c3
(c) c5
(d) all lines execute

Q36. [MSQ]
What is/are the problem(s) in this code?
(a) If producer acquire lock when buffer is full then deadlock can occurred.
(b) If consumer acquires lock when buffer is empty then deadlock can occurred.
(c) If producer produce item continuously and consumer doesn’t consume it then
buffer overflow condition is occurred.
(d) None of the above.

BASIC OPERATING SYSTEM Page 38


Q37. Consider the following solution to the Readers-Writers Problem:
Semaphore mutex, wrt;
int readcount;
mutex = 1;
wrt = 1;
readcount = 0;
Reader Process Writer Process
while(TRUE) while(TRUE)
{ {
wait(mutex); wait(wrt);
if(readcount == 1)
wait(wrt); //Perform Writing
signal(mutex);
signal(wrt);
//Perform Reading }

wait(mutex);
readcount--;
if(readcount == 0)
signal(wrt);
signal(mutex);
}
What is the problem associated with the above solution?
(a) Mutual Exclusion is not ensured in the above solution.
(b) Writer process cannot proceed, i.e., there is no progress.
(c) Multiple writer process can modify the data.
(d) There is no problem associated with the above solution.

Q38. Consider a semaphore implementation of reader writer problem:


int readers_count = 0;
semaphore mutex = 1;
binary semaphore data = 1;
1. void reader() { 1. void writer() {
2. while(TRUE) { 2. while(TRUE) {
3. wait(mutex); 3. wait(data);
4. readers_count = readers_count + 1; 4. < access Database >
5. if(readers_count == 1) wait(data); 5. signal(data);
6. signal(mutex); 6. }
7. }
7. < access Database >

8. wait(mutex);
9. readers_count = readers_count - 1;
10. if(readers_count == 0) signal(data);
11. signal(mutex);
12. }
13. }
What happens when positions of lines 10 and 11 in reader code are interchanged?
(a) No problem, the solution works fine.
(b) Multiple readers and writers or multiple writers are allowed in the database at the
same time.
(c) There is possibility of deadlock.
(d) None of the above
BASIC OPERATING SYSTEM Page 39
Q39. [MSQ]
Which of the following is a valid solution to the Dining Philosopher’s Problem
(guarantees that some philosopher will eat and the solution must be starvation free)?
(a) Number the chopsticks. Pick up the chopstick with the lower value first, then the
higher value
(b) Pick up the left chopstick first, then the right chopstick
(c)Pick up the left chopstick. If the right chopstick is not on the table, set the left
chopstick down.
(d) None of the above
Q40. [MSQ]
Consider the following two scenarios in the dining philosophers problem:
i. First a philosopher has to enter a room with the table that restricts the number of
philosophers to n-1.
ii. There is no restriction on the number of philosophers entering the room.
Which of the following is/are true?
(a) Deadlock is possible in both (i) and (ii).
(b) Deadlock is possible in (ii) only.
(c) Starvation is possible in both (i) and (ii).
(d) Starvation is possible in (i) only.
Q41. Consider a pseudo code semaphore implementation of the Dining Philosophers’
problem. The semaphores are initialized to 1.
while(true) {
status = "waiting"
wait(left)
wait(right)
status = “eating”
signal(left)
signal(right)
status = "thinking"
}
In the above pseudo code solution to the Dining Philosophers’ problem, what could
go wrong?
(a) An unlucky process might never be able to get both left and right forks
simultaneously, even though other processes are eating.
(b) All processes might pick up one fork causing deadlock.
(c) Nothing is wrong; this is a good solution to the problem.
(d) Some processes will get extra turns to eat on a regular basis, violating the principle
of fair treatment.

BASIC OPERATING SYSTEM Page 40


Q42. The following pseudo code shows a solution to the Dining Philosopher problem with
N philosophers, using an array of N semaphores (each initialized to 1) to represent
N chopsticks (for N>2).
while (1) {
think; // think
wait(chopstick[i]); // pick up left chopstick
wait(chopstick[(i+1)% N]); // pick up right chopstick
eat; // eat
signal(chopstick[i]); // put down left chopstick
signal(chopstick[(i+1)% N]); // put down right chopstick
}
Which of the following statements is TRUE?
(a) The solution is deadlock-free
(b) The solution doesn’t ensures fairness among philosophers
(c) The solution is suffered from deadlock
(d) The solution is starvation-free
Q43. [MSQ]
Consider the following resource allocation graph:

++
Which process (es) is/are in a deadlock?
(a) P2 only (b) P3 only (c) P2 and P3 only (d) All the above
Q44. [MSQ]
Which process (es) is/are in a deadlock in the following resource allocation graph?

(a) P1 only (b) P2 only (c) No process is/are in deadlock (d) P1, P2 and P3

BASIC OPERATING SYSTEM Page 41


Q45. Consider the following resource allocation graph.

Which of the following statement is true?


(a) System is in deadlock both processes P1 and P2 are blocked.
(b) System is in deadlock if P2’s request for R2 is granted first.
(c) System is in deadlock state if P1’s request for R2 is granted first.
(d) System is deadlock free.

Q46. Suppose here are n processes in the system and each one needs k instances of a
resources to complete. What would be the minimum number of resources that you
should keep in the system to ensure no deadlock in the system?
(a) n*k (b)n*k-n+1 (c)n*k+1 (d)n*k*k

Q47. A system is having 3 user processes each requiring 2 units of resource R. The minimum
number of units of R such that no deadlock will occur-_________

Q48. A computer has 6 tape drives, with n processes competing for it. Each process may need
2 drives. For which maximum values of n is the system deadlock free?
(a) 4 (b) 5 (c) 6 (d) 7

Q49. A system is having 3 user processes P1, P2 and P3 where P1 requires 2 units of resource
R, P2 requires 3 units of resource R, P3 requires 4 units of resource R. The minimum
number of units of R that ensures no deadlock is _____?

Q50. Consider a system having 𝑝 processes, where each process needs a maximum of 𝑚
instances of resource type R1. Given that there are 𝑟 instances of resource type R1 in
total, what is the minimum value of r to ensure that the system is deadlock-free?
(a) 𝑟 ≥ (𝑚 − 1) + 1 (b) 𝑟 ≥ (𝑚) + 1
(c) 𝑟 ≤ (𝑚 − 1) + 1 (d) 𝑟 ≤ (𝑚 − 1)

BASIC OPERATING SYSTEM Page 42


Q51. A system has five processes P1 through P5 and four resource types R1 through R4.
There are 2 units of each resource type. Given that:
P1 holds 1 unit of R1 and requests 1 unit of R4
P2 holds 1 unit of R3 and requests 1 unit of R2
P3 holds one unit of R2 and requests 1 unit of R3
P4 requests 1 unit of R4
P5 holds one unit of R3 and 1 unit of R2, and requests 1 unit of R3
Which of the following statement is correct?
(a) System is in unsafe state both processes P2, P3 and P5 are involved in deadlock.
(b) System is in unsafe state both processes P3 and P5 are involved in deadlock.
(c) System is in safe state with the safe sequence P1, P4, P2, P3, P5.
(d) System is in safe state with the safe sequence P2, P4, P5, P3, P1.
Q52. Suppose a system has six equivalent tape drives. Three concurrent processes P1, P2 and
P3 require three, two and four of these tape drives, respectively, to complete their
execution. At a given instance two, one and one of these tape drives are allocated to
these processes P1, P2 and P3 respectively. Which of the following allocations will
bring the system to an unsafe state?
(a) Allocating one tape drive to process P3
(b) Allocating one tape drive to P1 and another one to P3
(c) Allocating one tape drive to process P2
(d) Allocating two tape drives to process P3
Data for the next two questions. Consider the following snapshot of a system with five
processes (P1, P2, P3, P4, P5) and four resources (R1, R2, R3, R4). There are no current
outstanding queued unsatisfied requests.

Q53. Which of the following is the correct safe sequence?


(a) P1, P4, P5, P2, P3. (b) P1,P4, P2, P5, P3
(c) P1,P4, P2, P3, P5 (d) system is not in safe sequence

BASIC OPERATING SYSTEM Page 43


Q54. Consider the two independent request of each other
R1: Request from a process P3 arrives for (0, 4, 2, 0)
R2: Request from a process P2 arrives for (0, 1, 2, 0)
Which of the two requests is/are granted by the OS?
(a) R1 only
(b) R2 only
(c) Both R1 and R2
(d) Neither R1 and nor R2
Q55. Consider the following snapshot of a system:

From the perspective of deadlock avoidance using Banker’s algorithm, which one of
the following is true?
(a) The system is in safe state
(b) The system is not in safe state, but would be safe if one more instance of B were
available
(c) The system is not in safe state, but would be safe if one more instance of C were
available
(d) The system is not in safe state, but would be safe if one more instance of D were
available
Notes

BASIC OPERATING SYSTEM Page 44


Q56. Consider the following snapshot of a system with five processes (P1, P2, P3, P4, P5) and
4 resources (R1, R2, R3, R4). There are no outstanding queued unsatisfied requests.

Suppose that the number of available resources of each type is given in the table. What
is the lowest value of x for which this is a safe state?
(a) 0 (b) 1
(c) 2 (d) System always in deadlock for any value of x

Q57. Consider the following snapshot of a system's states, with three processes and four
allocatable resources. The current allocated and requested resources are as follows:
Current Allocated Current Need Available
Processes
R1 R2 R3 R4 R1 R2 R3 R4 R1 R2 R3 R4
A 2 1 1 1 1 0 0 0 0 0 1 1
B 1 1 0 1 0 2 X 2
C 1 1 Y 1 0 0 1 0
Where, X and Y are two unknowns. What should the relationship between X and Y be
to ensure all three processes can run to completion?
(a) X <= Y – 1 (b) X >= Y – 2
(c) X <= Y + 2 (d) X = Y
Q58. Suppose n processes, P1,…,Pn share m identical resource units, which can be reserved
and released one at a time. The maximum resource requirement of process Pi is si,
where si>0. Which one of the following is a sufficient condition for ensuring that
deadlock does not occur?
(a) ∀i, si<m
(b) ∀i, si<n
(c) ∑𝑛𝑖=1 s𝑖 < (𝑚 + 𝑛)
(d) ∑𝑛𝑖=1 s𝑖 < (𝑚 × 𝑛)

BASIC OPERATING SYSTEM Page 45


Data for the next two questions. Consider the following snapshot of a system running n
concurrent processes. Process i is holding Xi instances of a resource R, 1 ≤ i ≤ n. Assume that all
instances of R are currently in use. Further, for all i, process i can place a request for at most Yi
additional instances of R while holding the Xi instances it already has. Of the n processes, there
are exactly two processes p and q such that Yp = Yq = 0. Which one of the following conditions
guarantees that no other process apart from p and q can complete execution?
Q59. Which of the following can serve as a necessary condition to guarantee that the system
is not approaching a deadlock?
(a) Min (Xp, Xq) <Max (Yk) where k != p and k != q
(b) Xp + Xq >= Min (Yk) where k != p and k != q
(c) Max (Xp, Xq) > 1
(d) Min (Xp, Xq) > 1

Q60. Which one of the following conditions guarantees that no other process apart from p
and q can complete execution?
(a) Xp+Xq< Min{Yk| 1 ≤ k ≤ n, k ≠ p, k ≠ q}
(b) Xp + Xq < Max{Yk| 1 ≤ k ≤ n, k ≠ p, k ≠ q}
(c) Min(Xp, Xq) ≥ Min{Yk| 1 ≤ k ≤ n, k ≠ p, k ≠ q}
(d) Min(Xp, Xq) ≤ Max{Yk| 1 ≤ k ≤ n, k ≠ p, k ≠ q}

BASIC OPERATING SYSTEM Page 46


BASIC OPERATING SYSTEM Page 47
MEMORY MANAGMENT
Q1. In ............... there is no internal fragmentation and is more efficient use of main
memory.
(a) Fixed partitioning (b) Dynamic partitioning
(c) Virtual memory paging (d) Simple segmentation

Q2. In ………………… , there is a inefficient use of memory due to internal fragmentation.


(a) Fixed partitioning (b) Dynamic partitioning
(c) Virtual memory paging (d) Simple segmentation

Q3. In ……………….. , there is a inefficient use of processor due to the need for
compaction to counter external fragmentation.
(a) Fixed partitioning (b) Dynamic partitioning
(c) Virtual memory paging (d) Simple segmentation

Q4. [MSQ]
Which of the following statements is/are false?
(a) External fragmentation is a problem with fixed partitioning memory management
techniques.
(b) Internal fragmentation is a problem with variable partitioning memory management
techniques.
(c) Memory compaction is employed to counteract internal fragmentation.
(d) Dynamic relocation requires memory compaction.

Q5. [MSQ]
Which of the following statements is/are TRUE?
1. Memory compaction requires dynamic relocation.
2. First-Fit is a replacement algorithm.
3. Best-Fit generally causes less fragmentation than First-Fit.
4. A function of a linker is to combine several object modules into a single load
module.

BASIC OPERATING SYSTEM Page 48


Data for the next four questions. Suppose that we have free segments with sizes: 6, 17, 25,
14, and 12.
OS 6KB IN USE 17KB IN USE 25KB IN USE 14KB IN USE 12KB
Q6. If the placement algorithm is first-fit, then a program with size 13KB is placed in which
of the above free segment?
(a) 17 KB (b) 25 KB (c) 14 KB (d) 12 KB

Q7. If the placement algorithm is best-fit, then a program with size 13KB is placed in which
of the above free segment?
(a) 17 KB (b) 25 KB (c) 14 KB (d) 12 KB

Q8. If the placement algorithm is worst-fit, then a program with size 13KB is placed in
which of the above free segment?
(a) 17 KB (b) 25 KB (c) 14 KB (d) 12 KB

Q9. If the placement algorithm is next-fit and the last allocated segment is 14KB, then a
program with size 13KB is placed in which of the above free segment?
(a) 17 KB (b) 25 KB (c) 14 KB (d) 12 KB

Q10. Any .................. mechanism must have the flexibility to allow several processes to access
the same portion of main memory.
(a) Relocation (b) protection (c) sharing (d) organization

Data for the next three question. Suppose the free holes in memory is kept in a linked list of
H1(300KB), H2(200KB), H3(600KB), H4(100KB), and H5(500K), in that order. Four processes,
P1(189KB), P2(252KB), P3(433KB) and P4(525KB) arrive in that order. How will the processes
be placed in the free holes according to following three placement algorithms?
Q11. First-fit
(a) P1 in H2, P2 in H3, P3 in H5, P4 cannot be placed.
(b) P1 in H1, P2 in H3, P3 in H5, P4 cannot be placed
(c) P1 in H2, P2 in H4, P3 in H5, P4 in H3
(d) P1 in H1,P2 in H4, P3 in H3, P4 in H5

BASIC OPERATING SYSTEM Page 49


Q12. Best-fit
(a) P1 in H2, P2 in H1, P3 in H5, P4 in H3
(b) P1 in H1, P2 in H2, P3 in H3, P4 in H5
(c) P1 in H1, P2 in H3, P3 in H5, P4 cannot be placed
(d) None of the above

Q13. Worst-fit
(a) P1 in H2, P2 in H1, P3 in H5, P4 in H3
(b) P1 in H5, P2 in H3, P3 and P4 cannot be placed
(c) P1 in H3, P2 in H5, P3 and P4 cannot be placed
(d) P1 in H1, P2 in H3, P3 in H5, P4 cannot be placed

Q14. A computer provides the user with virtual address space of 230 words or 1G word. Pages
of size 1024 words or 1K word are used for implementing virtual memory where the
byte addressable main memory is equal to 220 bytes or 1MB. If the virtual address is
(11223344)16 and the word size is 32-bits, then the value of page number and page offset
in decimal respectively is
(a) 11223, 344 (b) 280716, 836
(c) 4488C, 344 (d) 70179, 836

Q15. Consider a logical address space of 64 pages of 1024 words each, mapped onto a physical
memory of 32 frames. If the physical memory is word addressable and word size is 32-
bits, then the number of bits is in the logical address and in the physical address
respectively is
(a) 15, 16 (b) 16, 15
(c) 18, 17 (d) 17, 18
Data for the next four questions. Consider the virtual memory system with 42-bit virtual
addresses and 38-physical addresses, in which memory is allocated in 8 KB pages. Suppose a
single-level page table is used, in which you also store three metadata bits for each page:
Writable, Executable and Valid.
Q16. How long, in bits, is a virtual page number? ________

Q17. How long, in bits, is a physical page number? _______

BASIC OPERATING SYSTEM Page 50


Q18. How long, in bits, is an offset within a page? ________

Q19. Assume that page table entries are stored in multiple of 8. How long, in bytes, page
table entry? _______

Q20. A computer provides the user with virtual address space of 232 bytes or 4 GB. Pages of
size 4096 bytes or 4KB are used for implementing virtual memory where the byte
addressable main memory is equal to 220 bytes or 1MB. If the virtual address is
(12345678)16, then the value of page offset in decimal is____________

Q21. A computer provides the user with virtual address space of 232 bytes or 4 GB. Pages of
size 4096 bytes or 4KB are used for implementing virtual memory where the byte
addressable main memory is equal to 220 bytes or 1MB. If the virtual address is
(12345678)16, then the value of page number in decimal is___________
Q22. A computer provides the user with virtual address space of 230 bytes (or 1 GB). Pages
of size 1024 bytes (or 1KB) are used for implementing virtual memory where the byte
addressable main memory is equal to 220 bytes or 1MB. If the virtual address is
(12345678)16, then the value of page offset in decimal is___________

Q23. A computer provides the user with virtual address space of 230 bytes or 1 GB. Pages of
size 1024 bytes or 1KB are used for implementing virtual memory where the byte
addressable main memory is equal to 220 bytes or 1MB. If the virtual address is
(12345678)16, then the value of page number in decimal is_________
Q24. Assume a virtual memory addressing space of 16 GB and a physical memory addressing
space of 4 GB. Let the size of a page be 4 Kbytes. The number of page table entries in the
single level page table is_______
Data for the next two questions. A paging system uses 16-bit address and 4K pages. The
following shows the page tables of two running processes, Process 1 and Process 2. Translate
the logical addresses in the table below to their corresponding physical addresses.

Q25. The physical address corresponding to logical address 11034 generated by process 1(in
decimal)_______

BASIC OPERATING SYSTEM Page 51


Q26. The physical address corresponding to logical address 12345 generated by process 2(in
decimal)_________
Data for the next four questions. Consider a user program of logical address of size 6 pages
and page size is 4 bytes. The physical address contains 300 frames. The user program consists
of 22 instructions a, b, c, . . . u, v. Each instruction takes 1 byte. The logical map, physical page
and the page table are shown in figure:

Q27. What is the physical addresses for the instructions m? ________

Q28. What is the physical addresses for the instructions d? ________

Q29. What is the physical addresses for the instructions v? ________

Q30. What is the physical addresses for the instructions r? ________

Q31. Consider the virtual memory system with 42-bit virtual addresses and 38-physical
addresses, in which memory is allocated in 8 KB pages. Suppose a single-level page table
is used, in which you also store three metadata bits for each page: Writable, Executable
and Valid. How many pages are required to store the page table of each process?
____________

BASIC OPERATING SYSTEM Page 52


Q32. Assuming a page size of 1 KB and that each page table entry (PTE) takes 4bytes, how
many levels of page tables would be required to map a 34-bit virtual address if every
page table fits into a single page.
(a) 2 (b) 3 (c) 4 (d) 5

Q33. Consider a machine with a physical memory of 8 GB, a page size of 8 KB, and a page
table entry size of 4 bytes. How many levels of page tables would be required to map a
46-bit virtual address space if every page table fits into a single page? ___________.
Data for the next five questions. Consider the virtual memory system with 32-bit virtual
addresses, 25-bits physical addresses and a page size of 4 KB or 4096 bytes. Suppose a single-
level page table is used, and each entry of page table store three metadata bits for each page.
Assume that page table entries are always byte aligned.
Q34. How many bits of each virtual address are needed to represent the page number? ___.

Q35. How many bits of each physical address are needed to represent the frame number? _.

Q36. How many bits of each virtual address are needed to represent the page offset? ______

Q37. How many bytes are required to represent page table entry? ________

Q38. How much memory is required to store single level page table of each process?
(a) 1 MB (b) 2 MB (c) 3 MB (d) 4 MB
Data For the next two questions, consider a virtual memory system with the following
properties:
 12-bit virtual byte address
 256-byte pages
 65536 bytes of physical memory
The system uses a single level page table. The contents of the page table are partially shown
below (where VPN: Virtual page number and PPN: Physical page number)

Q39. What is the total size of the page table(in byte) for each process on this machine,
assuming that the valid, protection, dirty, and use bits take a total of 4 bits and that all
the virtual pages are in use?________

BASIC OPERATING SYSTEM Page 53


Q40. The physical address corresponding to the virtual addresses 0xAE2 is
(a) 0xFCE2 (b)0xF2E2 (c)0xFEE2 (d)0xFDE2

Data for the next four questions. Consider a paged virtual memory system. Suppose the page
table for the process currently executing on the processor looks like the following.

All numbers are decimal, everything is numbered starting from zero, and all addresses are
memory byte addresses. The page size is 1024 bytes.
Q41. If the virtual address is 4000, then the physical address in decimal is
(a) 928 (b) 7341
(c) 3130 (d) page fault

Q42. If the virtual address is 2221, then the physical address in decimal is
(a) 928 (b) 7341
(c) 3130 (d) page fault

Q43. If the virtual address is 1052, then the physical address in decimal is
(a) 928 (b) 7341
(c) 3130 (d) page fault

Q44. If the virtual address is 52, then the physical address in decimal is
(a) 928 (b) 7341
(c) 3124 (d) 3130

Data for the next two questions. A CPU generates 40 - bit virtual addresses which is converted
into 32 - bits physical address using TLB. The page size is 8 KB. The processor has a translation
look-aside buffer (TLB) which can hold a total of 64 page table entries and is 16-way set
associative.
Q45. Assume that the TLB tag does not store any process id. The minimum length of the TLB
tag in bits is:________

BASIC OPERATING SYSTEM Page 54


Q46. Assume that each TLB entry holds a TAG and its corresponding physical page number
and 4 status bits. What is the entry size of the TLB?

Data for the next two questions. Imagine a system has the following parameters:
 Virtual addresses are 18 bits wide.
 Physical addresses are 16 bits wide.
 The page size is 1024 bytes.
 The TLB is 4-way set associative with 16 total entries.
The contents of the TLB and the first 32 entries of the page table are shown as follows. All
numbers are given in hexadecimal.

Q47. For the given virtual addresses 0x1FAA4, what is the value of TLB index in
binary?_____ Solution: Page size = 1024 bytes number of bit required for it 10 bit

Q48. What is physical address corresponding to the virtual address? (in decimal)__________

BASIC OPERATING SYSTEM Page 55


For the next two questions, the following list of virtual addresses as seen on a system
sequentially. Assume 4-KB pages and a four entry fully associative TLB with LRU replacement
policy.
0x0FFF, 0x7A28, 0x3DAD, 0x3A98, 0x1C19, 0x1000

Q49. Which of the following virtual addresses result into TLB Miss?
(a) 0x0FFF (b) 0x7A28
(c) 0x3DAD (d) 0x3A98
Q50. Which of the following virtual addresses result into page fault?
(a) 0x3DAD (b) 0x3A98
(c) 0x1C19 (d) 0x7000
Data for the next three questions. Consider processor with 32-bit virtual addresses. The
memory management unit expects a two-level page table. Each process has a page directory,
each entry of which can point to a page table. The upper 6 bits of an address determine the page
directory index, the next 10 bits determine the index in the second-level page table, and the
bottom 16 bits determine the offset.
Q51. How many entries are in a page directory? ___________
(a) 64 (b) 1024 (c) 65536 (d) none of the above

Q52. How many entries are in a second-level page table?


(a) 64 (b) 1024 (c) 65536 (d) 4096

Q53. What is the maximum number of virtual pages per process?


(a) 256 x 210 (b) 32 x 210 (c) 128 x 210 (d) 64 x 210

BASIC OPERATING SYSTEM Page 56


Data for the next two questions. Consider a system using multi-level paging environment.
Virtual Address bits are divided as follows: Here first 8 bits represent the required bits for first
level, next 8 bits represent the required bits for second level, next 8 bits represent the required
bits for third level and last 10 bits represents the offset. Assume each page table entry is 4 bytes.
Q54. What is the amount of memory (in MB) required for storing the all page tables for a
maximum size process? ______________(Rounded off to two decimal places)

Q55. What is the size of memory (in bytes) required for storing the all page tables for a process
that requires 1 MB of memory?

Data for the next two questions. Consider a processor has virtual address 50-bits, the physical
address is 32 bits and the page size is 16KB. Each individual table at any level of the page table
occupies a single page of physical memory. Using multilevel paging, consider page table entry
requires additional 14 bits for the special purpose?
Q56. Which of the following is the correct division of virtual address?
(a) <12, 12, 12, 14 > (b) <6, 10, 10, 10, 14 >
(c) <10, 12, 14, 14 > (d) <14, 12, 10, 14>

Q57. How many entries are there in each individual page table?_____________

Q58. Consider the following segment table:


Segment Base Length
0 219 600
1 2300 14
2 90 100
3 1327 580
4 1952 96
Assume that the first digit represents the segment number, which reference is illegal?
(a) 0,430 (b) 1,10 (c) 2,500 (d) 3,400

BASIC OPERATING SYSTEM Page 57


Q59. [MSQ]
Consider the following segment table:
Segmen Base Limi
t Address t
0 200 500
1 2000 50
2 100 90
3 1000 900
Assuming that the first digit represents the segment number, which of the following
logical addresses is/are valid?
(i) 0400 (ii) 3100 (iii) 1060 (iv) 3900 (v) 2089
(a) Only i, ii and v (b) Only iii and iv
(c) Only iii and iv (d) Only iii, iv and v

For the next six questions, consider an architecture using segmentation with paging. In this
architecture, the 32-bit virtual address is divided into fields as follows:
4 bit segment number 12 bit page number 16 bit offset
Here are the relevant tables (all values in hexadecimal):
Segment Table Page Table A Page Table B
0 Page Table A 0 CAFE 0 F000
1 Page Table B 1 DEAD 1 D8BF
X (rest invalid) 2 BEEF X (rest invalid)
3 BA11
x (rest invalid)
Q60. Number of segments
(a) 4 (b) 8 (c) 16 (d) 32
Q61. Maximum size of each segment
(a) 4 MB (b) 64 MB (c) 256 MB (d) 32 MB
Q62. Size of each page
(a) 4 KB (b) 64 KB (c) 256 KB (d) 32 KB
Q63. Maximum number of pages per segment.
(a) 4 K (b) 64 K (c) 256 K (d) 32 K

BASIC OPERATING SYSTEM Page 58


Q64. Maximum size of each page table (per segment). Assume PTE requires 4 bytes.
(a) 16 KB (b) 64 KB
(c) 256 KB (d) 32 KB

Q65. Find the physical address corresponding to each of the following virtual addresses
(answer "bad virtual address" if the virtual address is invalid):
Virtual addresses: i. 00000000 ii. 20022002 iii. 10015555
Physical addresses: a. 0xD8BF5555 b. 0xCAFE0000 c. bad virtual address
(a) i-a, ii-b, iii-c
(b) i-b, ii-c, iii-a
(c) i-b, ii-a, iii-c
(d) None of these

Q66. A machine has 48-bit virtual addresses and 32-bit physical addresses. Pages are 8K. How
many entries are needed for an inverted page table?
(a) 219 (b) 235
(c) 232 (d) 24
For the next two questions, consider the following information:
 32-bit virtual address space
 4 KB page size
 4 GB physical memory
 16 bits for process ID
 12 bits of access information
 4 byte page table entry size
 Each single-level page table entry stores bits for access information and physical page
number.
 Each inverted page table entry stores bits for access information, process ID and virtual page
number.
 Assume that page table entries are always byte aligned.
Q67. How much space (in MB) is needed in memory for a single-level page table? _____

Q68. How much space (in MB) is needed in memory for an inverted page table? _______

BASIC OPERATING SYSTEM Page 59


For next three questions, consider a paging system with the page table stored in main
memory.
Q69. If a memory reference takes 200 nanoseconds, how long does a paged memory reference
take? ______ns.

Q70. If we add TLB, and 75% of all page-table references are found in the TLB, what is the
effective memory reference time? (Assume that finding a page-table entry in the TLB
takes zero time, if the entry is there.)_________ns.
Q71. What if the time to access the TLB is actually 2 ns and 75% of all page references are found
in TLB? _______ns.

Q72. Consider a paging system with the single level page table, which is stored in memory. A
memory reference takes 200 nanoseconds to access a page in memory, and a page fault
takes 400 nanoseconds. If 75% of all page-table references are found in the physical
memory, what is the effective address translation time?_________ns.

Q73. A computer system has a page fault rate is 60% and page fault service time is 25
milliseconds and a memory access time is 100 ns, the effective access time with single
level page table in ms is____________

Data for the next four questions. Suppose that:


 TLB lookup time = 20 ns
 TLB hit ratio = 99%
 Memory access time = 100 ns
 Page fault rate = 0.05%
 Swap page time (in or out) = 5000,000 ns
Q74. What is the total access time if the page is found in the TLB?
(a) 20 ns (b) 100 ns (c) 120 ns (d) 220 ns

Q75. What is the total access time if the page is not found in the TLB but is found in the page
table?
(a) 20 ns (b) 100 ns (c) 120 ns (d) 220 ns

Q76. What is the total access time if a page is not found in the TLB and the page table
(assume that all pages currently in memory are dirty)?
(a) 10000120 ns (b) 10000200 ns (c) 10000020 ns (d) 5000220 ns

BASIC OPERATING SYSTEM Page 60


Q77. What is the effective access time (in ns) if we assume that 50 % pages currently in memory
are dirty?____________(Rounded off to two decimal place)

Q78. Assume that a main memory access takes 100 ns. If we are using a two-level page table
and have a 50% TLB hit ratio, the effective memory access time is (assume no memory
cache and no page faults):
(a) 100 ns (b) 200 ns (c) 300 ns (d) 400 ns

Q79. Let TLB hit ratio is 80% and assume memory access time is 100 ns. One TLB miss requires
extra memory access to the page table for the frame number. The Effective Access Time
to read a virtual address is ______ % slowdown, compared to no-paging.

Q80. What is the probability of a page fault, using demand paging, if the effective access time
is 10microseconds, the RAM access time is 250 nanoseconds, and the page fault time is
200 milliseconds? Assume that accessing the page table entry takes no time.
(a) 0.0049 % (b) 1 % (c) 0.00025 % (d) 0.5 %

Q81. Consider the following virtual page reference string:7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0,


1, 7, 0, 1. How many page faults would occur if FIFO page replacement was used with
three frames in memory? _________

Q82. Consider a computer that has a page size of 1024 bytes. Consider the following virtual
address reference string for a
process:350,2054,3320,2441,2220,1321,3764,2944,5200,410,5011,4090,3550,25,100.
The number of page faults generated for this string when the page replacement policy is
optimal and there are three page frames are allocated to process is__________

Q83. What is the minimum number of page faults for an optimal page-replacement strategy
for the reference string 1,2,3,4,5,3,4,1,6,7,8,7,8,9,7,8,9,5,4,5,4,2 with four page
frames?____________
Q84. What is the minimum number of page faults for a FIFO page-replacement strategy
for the reference string 1,2,3,4,5,3,4,1,6,7,8,7,8,9,7,8,9,5,4,5,4,2 with three page
frames?____________
Q85. What is the minimum number of page faults for a LRU page-replacement strategy
For the reference string 1,2,3,4,5,3,4,1,6,7,8,7,8,9,7,8,9,5,4,5,4,2 with four page
frames?___________

BASIC OPERATING SYSTEM Page 61


Q86. What is the minimum number of page faults for a MRU page-replacement strategy
for the reference string 1,2,3,4,5,3,4,1,6,7,8,7,8,9,7,8,9,5,4,5,4,2 with three page
frames?____________

Q87. What is the minimum number of page faults for a Second Chance (clock) page-
replacement strategy for the reference string 1,2,3,4,5,3,4,1,6,7,8,7,8,9,7,8,9,5,4,5,4,2 with
three page frames?__________

Q88. Consider the following virtual page reference string:


1,2,3,4,5,3,4,1,6,7,8,7,8,9,7,8,9,5,4,5,4,.
Given a window size of 4 and assuming the primary memory is initially unloaded,
how many page faults will the given reference stream incur using the working set
model?_______

Q89. Consider the following page reference string: 1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6, 3, 2, 1, 2, 3,


6. At what minimum number of frame allocation the FIFO, LRU and Optimal page
replacement algorithms give the same number of page fault?______________
For the next two questions, Assume that you have a page-reference string for a process with
four frames (initially all empty). The page-reference string has length 15; 10 distinct page
numbers occur in it. Answer these questions for any page-replacement algorithms:
Q90. What is a lower bound on the number of page faults? ________

Q91. What is an upper bound on the number of page faults? _________

For next two questions you are given the following reference string for a process:
0123413123123121341341210
Q92. For the clock page replacement algorithm, let the number of page hits is x and the page
fault is y then what is the value of x+ y? If frame size is 3.
(a) 19 (b) 15 (c) 20 (d) 25

Q93. What is the working set (WS) at the end of the execution if Δ(window size) = 4)?
(a) {0,1,2} (b) {1,2,3,4} (c) {0,1,2,3} (d){4,1,2}

BASIC OPERATING SYSTEM Page 62


BASIC OPERATING SYSTEM Page 63
FILE SYSTEM AND DISK SCHEDULING
Q1. [MSQ]
Which one of the following statement is/are false?
(a) The memory usage of bitmapped free memory management depends on the amount
of memory in the disk.
(b) Linked list free memory management requires extra hardware.
(c) Linked list free memory management incurs more overhead when memory is freed.
(d) In hard-link implementation, OS maintains a link count initialized to 1.

Q2. [MSQ]
Which of the following statement is/are correct?
(a) A contiguous allocation is the best allocation policy.
(b) An indexed allocation policy affords faster information retrieval than the chained
allocation policy.
(c) Absolute path names begin by identifying path from the root.
(d) None of the above

Q3. Which two schemes are commonly used to manage disk free-space?
(a) Hash and linked list (b) Hash and bit-vector
(c) FIFO and bit-vector (d) Bit vector and linked list

Q4. The FAT approach is an optimization of which other approach? What optimization
does it perform?
(a) Linked (b) Indexed
(c) Contiguous (d) Extent-based

Q5. Extent-based allocation allows a file to consist of multiple contiguous regions instead
of just a single contiguous region. Therefore, when the file grows, if there is no free
space at the end of the last region, a new extent can be added.Extent-based allocations
allow files to grow more easily than which other allocation policy?
(a) Linked (b) Contiguous
(c) FAT (d) Multi-level Indexed

BASIC OPERATING SYSTEM Page 64


Q6. Which approach has the worst support for reading/writing files with a random-access
pattern? Why?
(a) Linked (b) Indexed
(c) Contiguous (d) FAT

Q7. Which allocation schemes suffer from internal fragmentation?


(a) Linked (b) Indexed
(c) FAT (d) All the mention

Q8. Which allocation schemes may limit the maximum size of a file to less than that of the
entire disk even when this is the only file on the disk?
(a) Linked (b) Contiguous
(c) FAT (d) Multi-level Indexed

Q9. Match the file allocation algorithm with the meta-data that it requires to track where all
of the file-data is located. Select the single best answer and use each response only once.
1. Linked a. Single pointer to file-data and its size
2. Indexed b. Array containing multiple pointers and their sizes
3. Contiguous c. Pointer to first block of file
4. Extent-based d. Array containing pointers to every block of file
(a) 1 – c, 2 – d, 3 – a, 4 – b (b) 1 – a, 2 – d, 3 – c, 4 – b
(c) 1 – c, 2 – a, 3 – d, 4 – b (d) 1 – a, 2 – d, 3 – b, 4 – c
Q10. Similarities exist between policies for allocating blocks on disk to files and policies for
allocating physical memory to processes. Match the file allocation policy with the most
similar memory allocation policy; note that each memory allocation policy may be used
more than once.
1. Linked a. Base and Bounds
2. Multi-level Indexed b. Paging
3. Contiguous c. Segmentation
4. Extent-based d. None of the above
5. FAT
(a) 1 – d, 2 – b, 3 – a, 4 – c, 5 – d (b) 1 – d, 2 – b, 3 – c, 4 – c, 5 – b
(c) 1 – d, 2 – b, 3 – c, 4 – a, 5 – b (d) 1 – b, 2 – b, 3 – c, 4 – c, 5 – b

BASIC OPERATING SYSTEM Page 65


Q11. In __________ allocation method for disk block allocation in a file system, insertion and
deletion of blocks in a file is easy.
(a) Index (b) Linked (d) Contiguous (d) Bit Map

Q12. Consider an index-based file system with a 2-level indexing. Assume that each index
takes 4 bytes. What is the maximum file size (in bytes) under this arrangement, if a disk
block is 1024 bytes?
(a) 218 (b) 226 (c) 216 (d) 228

Data for the next three questions. Consider a file system on a disk that has both logical and
physical block sizes of 512 bytes. Assume the information about each file is already in
memory. For each of the three allocation strategies (linked, contiguous, and indexed).
Suppose we are currently at logical block 10 (the last block assessed was block 10) and want
to access logical block 4. How many physical blocks must be read from the disk?
Q13. How many physical blocks must be read from the disk if the contiguous allocation
strategy is used?___________

Q14. How many physical blocks must be read from the disk if the indexes allocation strategy
is used?___________

Q15. Given a file of 100 blocks, what is the minimum number of disk I/O operations to insert
a block in the middle of the file if contiguous allocation is used (assume the block to be
inserted is already in memory)?
(a) 2 (b) 52 (c) 101 (d) 151

Q16. Given a file of 100 blocks, what is the minimum number of disk I/O operations needed
to insert a block in the middle of the file if linked list allocation is used (assume the
block to be inserted is already in the memory)?
(a) 2 (b) 52 (c) 101 (d) 151

For the next four questions, Consider an indexed file allocation using index nodes (Inodes).
An Inode contains among other things, 14 direct indexes, one indirect index, two double
indexes, and three triple indexes. If the system contains the 10485 files, size of disk is 1 PB and
disk sector is 1 Kbytes.
Q17. What is the size of Inode in this allocation scheme? _________Bytes

BASIC OPERATING SYSTEM Page 66


Q18. How much space of disk required storing the Inode of all the files (Approx.)?
_______bytes
Q19. How large of a file can be addressed by the double indirect block alone (Approx.)?
_________MB
Q20. What is the maximum file size in this allocation scheme (Approx.)? ____________ GB

Q21. A UNIX file system has 2-KB blocks and 8-byte disk addresses. The Inode of file ‘X’
requires 10 direct entries and an indirect block which is half full. How large is the file
in blocks?
(a) 138 (b) 264
(c) 520 (d) 1032

Q22. A Unix-style i-node has 12 direct pointers and one single, one double and one triple
indirect pointers. Disk block size is 8 Kbyte and disk block address is 64 bits
used. Assume that i-node table is in the main memory. How many disk I/O is required
to read the byte 16,000,000 of a file? ________

Q23. Consider a UNIX file system with 12 direct pointers, 1 indirect pointer, 1 double-
indirect pointer, and 1 triple-indirect pointer in the i-node. Assume that disk blocks are
1K bytes and that each pointer to a disk block requires 4 bytes. What is the largest
possible file (in GB) that can be supported with this design?_________(Rounded off to
two decimal place)
Q24. Consider a file system with 4096 byte blocks and 32-bit disk and file block pointers.
Each file has 13 direct pointers, 4 singly-indirect pointers, a doubly-indirect pointer,
and a triply-indirect pointer.What is the maximum disk size (in TB) that can be
supported?

For the next two questions, an engineer has designed a FAT-like system and he has used 24
bits for each entry. For a 32-GB disk.
Q25. What is the minimum size of a file allocation in this system?_______KB.

Q26. What is the smallest amount of memory that could possibly be used for the FAT?
________

BASIC OPERATING SYSTEM Page 67


Q27. A FAT (file allocation table) based file system is being used and the total overhead of
each entry in the FAT is 4 bytes in size. Given a 1 x 109 bytes disk on which the file
system is stored and data block size is 103 bytes, the maximum size of a file that can be
stored on this disk in units of 106 bytes is ____________.

Data for next four questions. Consider a file system that uses an FAT. The state of the
directory is
File name First block Size in bytes
AA 5 1350
BB 7 2200
(The other information in the directory is omitted)
The current state of the FAT is:
0 Free
1 Free
2 -1
3 4
4 -1
5 2
6 Free
7 3
8 Free
System uses a block of size 1K (and 1K=1024 bytes)
Q28. What is the last block of file AA? ______

Q29. How many bytes of last block of AA are used?______

Q30. What is the last block of file BB? ______

Q31. How many bytes of last block of BB are used? ________

BASIC OPERATING SYSTEM Page 68


Data for the next six questions. Suppose that a disk drive has 5000 cylinders, numbered 0 to
4999. The drive is currently serving a request at cylinder 143, and the previous request was at
cylinder 125. The queue of pending requests, in FIFO order, is 86, 1470, 913, 1774, 948, 1509,
1022, 1750 and 130. Starting from the current head position, what is the total distance (in
cylinders) that the disk head moves to satisfy all the pending requests for each of the following
disk scheduling algorithms?
Q32. FCFS: _________

Q33. SSTF: _________

Q34. SCAN: ________

Q35. LOOK: ________

Q36. C-SCAN:_______

Q37. C-LOOK:_______

Data for the next two questions. At time XZ, the request queue for a disk contains the
following requests in[track:sector] form: [10:5], [22:9], [20:21], [21:9], [2:10], [40:45], [6:7], [38:9]
…. (in this order).Assume that the disk head is currently positioned over cylinder 20. What is
the sequence of readsunder the following head scheduling algorithms?
Q38. Shortest Seek Time First:

(a) [20:21], [21:9], [22:9], [10:5], [6:7], [2:10], [38:9], [40:45]

(b) [20:21], [21:9], [22:9], [38:9], [40:45], [10:5], [6:7], [2:10]

(c) [6:7], [2:10], [38:9], [40:45], [20:21], [21:9], [22:9], [10:5]

(d) [40:45], [10:5], [6:7], [2:10], [20:21], [21:9], [22:9], [38:9]

Q39. SCAN (initially moving upwards):

(a) [20:21], [21:9], [22:9], [10:5], [6:7], [2:10], [38:9], [40:45]

(b) [20:21], [21:9], [22:9], [38:9], [40:45], [10:5], [6:7], [2:10]

(c) [6:7], [2:10], [38:9], [40:45], [20:21], [21:9], [22:9], [10:5]

(d) [40:45], [10:5], [6:7], [2:10], [20:21], [21:9], [22:9], [38:9]

BASIC OPERATING SYSTEM Page 69


Q40. A disk has 300 cylinders. The head is currently over cylinder 20 heading outwards
(towards higher numbered cylinders). At time t=0 we have a queue of requests for
blocks on different cylinders: 25, 36, 28, 124, 56, 18, 178, 236. If we assume moving X
cylinders required X units of time, then how long will it take to visit all cylinders using
SSTF policy:
(a) 108
(b) 220
(c) 160
(d) None of the option

Q41. An OS uses the LOOK algorithm to schedule the disk-arm. I/O requests are currently
pending for blocks on tracks 1, 3, 8, 11, 15, and 16. The disk arm is currently at track 9
and moving upwards. In what order will these requests be handled?
(a) 11, 15, 16, 8, 3, 1
(b) 1,3,8 ,11,15,16
(c) 8,3,1 ,11,15,16
(d) 11, 15, 16, 1,3,8

Q42. Let there be the following requests for data blocks in tracks number 100, 175, 51, 133, 8,
140, 73, and 77 and let the head position be in track number 63 moving towards higher
tracks. Assuming that track number ranges between 0 to 200, what is the number of
tracks that will be traversed with the LOOK disk scheduling algorithm?
(a) 646
(b) 279
(c) 280
(d) 329

Q43. Which of the following disk scheduling strategies is likely to give the best throughput?
(a) Farthest cylinder next
(b) Nearest cylinder next
(c) First come first served
(d) Elevator algorithm

BASIC OPERATING SYSTEM Page 70


Q44. Suppose the following disk request sequence (track numbers) for a disk with 100 tracks
(Consider 1 to 100) is given: 45, 20, 90, 10, 50, 60, 80, 25, and 70. Assume that the initial
position of the R/W head is on track 50. The distance that Will be traversed by the R/W
head when the Shortest Seek Time First (SSTF) algorithm is x and the Distance that will
be traversed by the SCAN (Elevator) algorithm is y (assuming that SCAN algorithm
moves towards 100 when it starts execution) than what is the result of x-y?________
tracks
Q45. Consider a storage disk with 4 platters (numbered as 0, 1, 2 and 3), 200 cylinders
(numbered as 0, 1, …, 199), and 256 sectors per track (numbered as 0, 1, … 255). The
following 6 disk requests of the form [sector number, cylinder number, platter number]
are received by the disk controller at the same time in the order: [120, 72, 2], [180, 134,
1], [60, 20, 0], [212, 86, 3], [56, 116, 2], [118, 16, 1]. Currently R/W head is positioned at
sector number 100 of cylinder 80, and is moving towards higher cylinder numbers. The
total distance that will be traversed by the R/W head when the Shortest Seek Time First
(SSTF) algorithm is used is______________

BASIC OPERATING SYSTEM Page 71


BASIC OPERATING SYSTEM Page 72

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy