6 ch3,4

Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

This set of Operating System Multiple Choice Questions & Answers (MCQs) focuses on

“CPU Scheduling”.

1. Which module gives control of the CPU to the process selected by the short-term
scheduler?
a) dispatcher
b) interrupt
c) scheduler
d) none of the mentioned
View Answer
Answer: a
Explanation: None.

2. The processes that are residing in main memory and are ready and waiting to execute
are kept on a list called _____________
a) job queue
b) ready queue
c) execution queue
d) process queue
View Answer
Answer: b
Explanation: None.

3. The interval from the time of submission of a process to the time of completion is termed
as ____________
a) waiting time
b) turnaround time
c) response time
d) throughput
View Answer
Answer: b
Explanation: None.

4. Which scheduling algorithm allocates the CPU first to the process that requests the CPU
first?
a) first-come, first-served scheduling
b) shortest job scheduling
c) priority scheduling
d) none of the mentioned
View Answer
Answer: a
Explanation: None.

5. In priority scheduling algorithm ____________


a) CPU is allocated to the process with highest priority
b) CPU is allocated to the process with lowest priority
c) Equal priority processes can not be scheduled
d) None of the mentioned
View Answer
Answer: a
Explanation: None.

6. In priority scheduling algorithm, when a process arrives at the ready queue, its priority is
compared with the priority of ____________
a) all process
b) currently running process
c) parent process
d) init process
View Answer
Answer: b
Explanation: None.

7. Which algorithm is defined in Time quantum?


a) shortest job scheduling algorithm
b) round robin scheduling algorithm
c) priority scheduling algorithm
d) multilevel queue scheduling algorithm
View Answer
Answer: b
Explanation: None.

8. Process are classified into different groups in ____________


a) shortest job scheduling algorithm
b) round robin scheduling algorithm
c) priority scheduling algorithm
d) multilevel queue scheduling algorithm
View Answer
Answer: d
Explanation: None.

9. In multilevel feedback scheduling algorithm ____________


a) a process can move to a different classified ready queue
b) classification of ready queue is permanent
c) processes are not classified into groups
d) none of the mentioned
View Answer
Answer: a
Explanation: None.

10. Which one of the following can not be scheduled by the kernel?
a) kernel level thread
b) user level thread
c) process
d) none of the mentioned
View Answer
Answer: b
Explanation: User level threads are managed by thread library and the kernel is unaware of
them.

This set of Operating System Multiple Choice Questions & Answers (MCQs) focuses on
“CPU Scheduling Benefits”.

1. CPU scheduling is the basis of ___________


a) multiprocessor systems
b) multiprogramming operating systems
c) larger memory sized systems
d) none of the mentioned
View Answer
Answer: b
Explanation: None.
2. With multiprogramming ______ is used productively.
a) time
b) space
c) money
d) all of the mentioned
View Answer
Answer: a
Explanation: None.

3. What are the two steps of a process execution?


a) I/O & OS Burst
b) CPU & I/O Burst
c) Memory & I/O Burst
d) OS & Memory Burst
View Answer
Answer: b
Explanation: None.

4. An I/O bound program will typically have ____________


a) a few very short CPU bursts
b) many very short I/O bursts
c) many very short CPU bursts
d) a few very short I/O bursts
View Answer
Answer: c
Explanation: None.

5. A process is selected from the ______ queue by the ________ scheduler, to be


executed.
a) blocked, short term
b) wait, long term
c) ready, short term
d) ready, long term
View Answer
Answer: c
Explanation: None.
6. In the following cases non – preemptive scheduling occurs?
a) When a process switches from the running state to the ready state
b) When a process goes from the running state to the waiting state
c) When a process switches from the waiting state to the ready state
d) All of the mentioned
View Answer
Answer: b
Explanation: There is no other choice.
7. The switching of the CPU from one process or thread to another is called ____________
a) process switch
b) task switch
c) context switch
d) all of the mentioned
View Answer
Answer: d
Explanation: None.

8. What is Dispatch latency?


a) the speed of dispatching a process from running to the ready state
b) the time of dispatching a process from running to ready state and keeping the CPU idle
c) the time to stop one process and start running another one
d) none of the mentioned
View Answer
Answer: c
Explanation: None.

9. Scheduling is done so as to ____________


a) increase CPU utilization
b) decrease CPU utilization
c) keep the CPU more idle
d) none of the mentioned
View Answer
Answer: a
Explanation: None.

10. Scheduling is done so as to ____________


a) increase the throughput
b) decrease the throughput
c) increase the duration of a specific amount of work
d) none of the mentioned
View Answer
Answer: a
Explanation: None.

11. What is Turnaround time?


a) the total waiting time for a process to finish execution
b) the total time spent in the ready queue
c) the total time spent in the running queue
d) the total time from the completion till the submission of a process
View Answer
Answer: d
Explanation: None.

12. Scheduling is done so as to ____________


a) increase the turnaround time
b) decrease the turnaround time
c) keep the turnaround time same
d) there is no relation between scheduling and turnaround time
View Answer
Answer: b
Explanation: None.

13. What is Waiting time?


a) the total time in the blocked and waiting queues
b) the total time spent in the ready queue
c) the total time spent in the running queue
d) the total time from the completion till the submission of a process
View Answer
Answer: b
Explanation: None.

14. Scheduling is done so as to ____________


a) increase the waiting time
b) keep the waiting time the same
c) decrease the waiting time
d) none of the mentioned
View Answer
Answer: c
Explanation: None.

15. What is Response time?


a) the total time taken from the submission time till the completion time
b) the total time taken from the submission time till the first response is produced
c) the total time taken from submission time till the response is output
d) none of the mentioned
View Answer
Answer: b
Explanation: None.

This set of Operating System Multiple Choice Questions & Answers (MCQs) focuses on
“CPU Scheduling Algorithms-1”.

1. Round robin scheduling falls under the category of ____________


a) Non-preemptive scheduling
b) Preemptive scheduling
c) All of the mentioned
d) None of the mentioned
View Answer
Answer: b
Explanation: None.

2. With round robin scheduling algorithm in a time shared system ____________


a) using very large time slices converts it into First come First served scheduling algorithm
b) using very small time slices converts it into First come First served scheduling algorithm
c) using extremely small time slices increases performance
d) using very small time slices converts it into Shortest Job First algorithm
View Answer
Answer: a
Explanation: All the processes will be able to get completed.
3. The portion of the process scheduler in an operating system that dispatches processes is
concerned with ____________
a) assigning ready processes to CPU
b) assigning ready processes to waiting queue
c) assigning running processes to blocked queue
d) all of the mentioned
View Answer
Answer: a
Explanation: None.
4. Complex scheduling algorithms ____________
a) are very appropriate for very large computers
b) use minimal resources
c) use many resources
d) all of the mentioned
View Answer
Answer: a
Explanation: Large computers are overloaded with a greater number of processes.

5. What is FIFO algorithm?


a) first executes the job that came in last in the queue
b) first executes the job that came in first in the queue
c) first executes the job that needs minimal processor
d) first executes the job that has maximum processor needs
View Answer
Answer: b
Explanation: None.

6. The strategy of making processes that are logically runnable to be temporarily suspended
is called ____________
a) Non preemptive scheduling
b) Preemptive scheduling
c) Shortest job first
d) First come First served
View Answer
Answer: b
Explanation: None.

7. What is Scheduling?
a) allowing a job to use the processor
b) making proper use of processor
c) all of the mentioned
d) none of the mentioned
View Answer
Answer: a
Explanation: None.

8. There are 10 different processes running on a workstation. Idle processes are waiting for
an input event in the input queue. Busy processes are scheduled with the Round-Robin
time sharing method. Which out of the following quantum times is the best value for small
response times, if the processes have a short runtime, e.g. less than 10ms?
a) tQ = 15ms
b) tQ = 40ms
c) tQ = 45ms
d) tQ = 50ms
View Answer
Answer: a
Explanation: None.

9. Orders are processed in the sequence they arrive if _______ rule sequences the jobs.
a) earliest due date
b) slack time remaining
c) first come, first served
d) critical ratio
View Answer
Answer: c
Explanation: None.

10. Which of the following algorithms tends to minimize the process flow time?
a) First come First served
b) Shortest Job First
c) Earliest Deadline First
d) Longest Job First
View Answer
Answer: b
Explanation: None.
11. Under multiprogramming, turnaround time for short jobs is usually ________ and that
for long jobs is slightly ___________
a) Lengthened; Shortened
b) Shortened; Lengthened
c) Shortened; Shortened
d) Shortened; Unchanged
View Answer
Answer: b
Explanation: None.

12. Which of the following statements are true? (GATE 2010)

I. Shortest remaining time first scheduling may cause starvation

II. Preemptive scheduling may cause starvation

III. Round robin is better than FCFS in terms of response time

a) I only
b) I and III only
c) II and III only
d) I, II and III
View Answer
Answer: d
Explanation: I) Shortest remaining time first scheduling is a preemptive version of shortest
job scheduling. It may cause starvation as shorter processes may keep coming and a long
CPU burst process never gets CPU.
II) Preemption may cause starvation. If priority based scheduling with preemption is used,
then a low priority process may never get CPU.
III) Round Robin Scheduling improves response time as all processes get CPU after a
specified time.

This set of Operating System Questions and Answers for Freshers focuses on “CPU
Scheduling Algorithms-2” and will also be useful for interview preparations for freshers.

1. Which is the most optimal scheduling algorithm?


a) FCFS – First come First served
b) SJF – Shortest Job First
c) RR – Round Robin
d) None of the mentioned
View Answer
Answer: b
Explanation: None.
2. The real difficulty with SJF in short term scheduling is ____________
a) it is too good an algorithm
b) knowing the length of the next CPU request
c) it is too complex to understand
d) none of the mentioned
View Answer
Answer: b
Explanation: None.

3. The FCFS algorithm is particularly troublesome for ____________


a) time sharing systems
b) multiprogramming systems
c) multiprocessor systems
d) operating systems
View Answer
Answer: a
Explanation: In a time sharing system, each user needs to get a share of the CPU at regular
intervals

.
4. Consider the following set of processes, the length of the CPU burst time given in
milliseconds.

Process Burst time


P1 6
P2 8
P3 7
P4 3

Assuming the above process being scheduled with the SJF scheduling algorithm.
a) The waiting time for process P1 is 3ms
b) The waiting time for process P1 is 0ms
c) The waiting time for process P1 is 16ms
d) The waiting time for process P1 is 9ms
View Answer
Answer: a
Explanation: None.

5. Preemptive Shortest Job First scheduling is sometimes called ____________


a) Fast SJF scheduling
b) EDF scheduling – Earliest Deadline First
c) HRRN scheduling – Highest Response Ratio Next
d) SRTN scheduling – Shortest Remaining Time Next
View Answer
Answer: d
Explanation: None.

6. 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
View Answer
Answer: a
Explanation: The larger the CPU burst, the lower the priority.

7. Choose one of the disadvantages of the priority scheduling algorithm?


a) it schedules in a very complex manner
b) its scheduling takes up a lot of time
c) it can lead to some low priority process waiting indefinitely for the CPU
d) none of the mentioned
View Answer
Answer: c
Explanation: None.

8. What is ‘Aging’?
a) keeping track of cache contents
b) keeping track of what pages are currently residing in memory
c) keeping track of how many times a given page is referenced
d) increasing the priority of jobs to ensure termination in a finite time
View Answer
Answer: d
Explanation: None.

9. A solution to the problem of indefinite blockage of low – priority processes is


____________
a) Starvation
b) Wait queue
c) Ready queue
d) Aging
View Answer
Answer: d
Explanation: None.

10. Which of the following statements are true? (GATE 2010)

i) Shortest remaining time first scheduling may cause starvation

ii) Preemptive scheduling may cause starvation

iii) Round robin is better than FCFS in terms of response time

a) i only
b) i and iii only
c) ii and iii only
d) i, ii and iii
View Answer
Answer: d
Explanation: None.

11. Which of the following scheduling algorithms gives minimum average waiting time?
a) FCFS
b) SJF
c) Round – robin
d) Priority
View Answer
Answer: b
Explanation: None.

This set of Operating System Multiple Choice Questions & Answers (MCQs) focuses on
“The Critical Section (CS) Problem and Solutions”.

1. Concurrent access to shared data may result in ____________


a) data consistency
b) data insecurity
c) data inconsistency
d) none of the mentioned
View Answer
Answer: c
Explanation: None.

2. A situation where several processes access and manipulate the same data concurrently
and the outcome of the execution depends on the particular order in which access takes
place is called ____________
a) data consistency
b) race condition
c) aging
d) starvation
View Answer
Answer: b
Explanation: None.

3. The segment of code in which the process may change common variables, update
tables, write into files is known as ____________
a) program
b) critical section
c) non – critical section
d) synchronizing
View Answer
Answer: b
Explanation: None.

4. Which of the following conditions must be satisfied to solve the critical section problem?
a) Mutual Exclusion
b) Progress
c) Bounded Waiting
d) All of the mentioned
View Answer
Answer: d
Explanation: None.

5. Mutual exclusion implies that ____________


a) if a process is executing in its critical section, then no other process must be executing in
their critical sections
b) if a process is executing in its critical section, then other processes must be executing in
their critical sections
c) if a process is executing in its critical section, then all the resources of the system must
be blocked until it finishes execution
d) none of the mentioned
View Answer
Answer: a
Explanation: None.

6. Bounded waiting implies that there exists a bound on the number of times a process is
allowed to enter its critical section ____________
a) after a process has made a request to enter its critical section and before the request is
granted
b) when another process is in its critical section
c) before a process has made a request to enter its critical section
d) none of the mentioned
View Answer
Answer: a
Explanation: None.

7. A minimum of _____ variable(s) is/are required to be shared between processes to solve


the critical section problem.
a) one
b) two
c) three
d) four
View Answer
Answer: b
Explanation: None.

8. In the bakery algorithm to solve the critical section problem ____________


a) each process is put into a queue and picked up in an ordered manner
b) each process receives a number (may or may not be unique) and the one with the lowest
number is served next
c) each process gets a unique number and the one with the highest number is served next
d) each process gets a unique number and the one with the lowest number is served next
View Answer
Answer: b
Explanation: None.

This set of Operating System Multiple Choice Questions & Answers (MCQs) focuses on
“Semaphores”.

1. An un-interruptible unit is known as ____________


a) single
b) atomic
c) static
d) none of the mentioned
View Answer
Answer: b
Explanation: None.

2. TestAndSet instruction is executed ____________


a) after a particular process
b) periodically
c) atomically
d) none of the mentioned
View Answer
Answer: c
Explanation: None.

3. Semaphore is a/an _______ to solve the critical section problem.


a) hardware for a system
b) special program for a system
c) integer variable
d) none of the mentioned
View Answer
Answer: c
Explanation: None.

4. What are the two atomic operations permissible on semaphores?


a) wait
b) stop
c) hold
d) none of the mentioned
View Answer
Answer: a
Explanation: None.

5. What are Spinlocks?


a) CPU cycles wasting locks over critical sections of programs
b) Locks that avoid time wastage in context switches
c) Locks that work better on multiprocessor systems
d) All of the mentioned
View Answer
Answer: d
Explanation: None.

6. What is the main disadvantage of spinlocks?


a) they are not sufficient for many process
b) they require busy waiting
c) they are unreliable sometimes
d) they are too complex for programmers
View Answer
Answer: b
Explanation: None.

7. The wait operation of the semaphore basically works on the basic _______ system call.
a) stop()
b) block()
c) hold()
d) wait()
View Answer
Answer: b
Explanation: None.

8. The signal operation of the semaphore basically works on the basic _______ system call.
a) continue()
b) wakeup()
c) getup()
d) start()
View Answer
Answer: b
Explanation: None.

9. If the semaphore value is negative ____________


a) its magnitude is the number of processes waiting on that semaphore
b) it is invalid
c) no operation can be further performed on it until the signal operation is performed on it
d) none of the mentioned
View Answer
Answer: a
Explanation: None.

10. The code that changes the value of the semaphore is ____________
a) remainder section code
b) non – critical section code
c) critical section code
d) none of the mentioned
View Answer
Answer: c
Explanation: None.

11. The following program consists of 3 concurrent processes and 3 binary semaphores.
The semaphores are initialized as S0 = 1, S1 = 0, S2 = 0.

Process P0
while(true)
{
wait(S0);
print '0';
release(S1);
release(S2);
}

Process P1
wait(S1);
release(S0);

Process P2
wait(S2);
release(S0);
How many times will P0 print ‘0’?
a) At least twice
b) Exactly twice
c) Exactly thrice
d) Exactly once
View Answer
Answer: a
Explanation: None.

12. Each process Pi, i = 0,1,2,3,……,9 is coded as follows.

repeat
P(mutex)
{Critical Section}
V(mutex)
forever

The code for P10 is identical except that it uses V(mutex) instead of P(mutex). What is the
largest number of processes that can be inside the critical section at any moment (the
mutex being initialized to 1)?
a) 1
b) 2
c) 3
d) None of the mentioned
View Answer
Answer: c
Explanation: Any one of the 9 processes can get into critical section after executing
P(mutex) which decrements the mutex value to 0. At this time P10 can enter critical section
by incrementing the value to 1. Now any of the 9 processes can enter the critical section by
again decrementing the mutex value to 0. None of the remaining processes can get into
their critical sections.

13. Two processes, P1 and P2, need to access a critical section of code. Consider the
following synchronization construct used by the processes.

Process P1 :
while(true)
{
w1 = true;
while(w2 == true);
Critical section
w1 = false;
}
Remainder Section
Process P2 :
while(true)
{
w2 = true;
while(w1 == true);
Critical section
w2 = false;
}
Remainder Section

Here, w1 and w2 have shared variables, which are initialized to false. Which one of the
following statements is TRUE about the above construct?
a) It does not ensure mutual exclusion
b) It does not ensure bounded waiting
c) It requires that processes enter the critical section in strict alternation
d) It does not prevent deadlocks but ensures mutual exclusion
View Answer
Answer: d
Explanation: None.

This set of Operating System Interview Questions and Answers for freshers focuses on
“Semaphores – 2” and will also be useful for interview preparations for freshers.

1. What will happen if a non-recursive mutex is locked more than once?


a) Starvation
b) Deadlock
c) Aging
d) Signaling
View Answer
Answer: b
Explanation: If a thread which had already locked a mutex, tries to lock the mutex again, it
will enter into the waiting list of that mutex, which results in a deadlock. It is because no
other thread can unlock the mutex.

2. What is a semaphore?
a) is a binary mutex
b) must be accessed from only one process
c) can be accessed from multiple processes
d) none of the mentioned
View Answer
Answer: c
Explanation: None.
3. What are the two kinds of semaphores?
a) mutex & counting
b) binary & counting
c) counting & decimal
d) decimal & binary
View Answer
Answer: b
Explanation: None.

4. What is a mutex?
a) is a binary mutex
b) must be accessed from only one process
c) can be accessed from multiple processes
d) none of the mentioned
View Answer
Answer: b
Explanation: None.

5. At a particular time of computation the value of a counting semaphore is 7.Then 20 P


operations and 15 V operations were completed on this semaphore. The resulting value of
the semaphore is? (GATE 1987)
a) 42
b) 2
c) 7
d) 12
View Answer
Answer: b
Explanation: P represents Wait and V represents Signal. P operation will decrease the
value by 1 every time and V operation will increase the value by 1 every time.

6. A binary semaphore is a semaphore with integer values ____________


a) 1
b) -1
c) 0.8
d) 0.5
View Answer
Answer: a
Explanation: None.
7. The following pair of processes share a common variable X.

Process A
int Y;
A1: Y = X*2;
A2: X = Y;

Process B
int Z;
B1: Z = X+1;
B2: X = Z;

X is set to 5 before either process begins execution. As usual, statements within a process
are executed sequentially, but statements in process A may execute in any order with
respect to statements in process B.
How many different values of X are possible after both processes finish executing?
a) two
b) three
c) four
d) eight
View Answer
Answer: c
Explanation: Here are the possible ways in which statements from A and B can be
interleaved.

A1 A2 B1 B2: X = 11
A1 B1 A2 B2: X = 6
A1 B1 B2 A2: X = 10
B1 A1 B2 A2: X = 10
B1 A1 A2 B2: X = 6
B1 B2 A1 A2: X = 12.

8. The program follows to use a shared binary semaphore T.

Process A
int Y;
A1: Y = X*2;
A2: X = Y;
signal(T);

Process B
int Z;
B1: wait(T);
B2: Z = X+1;
X = Z;

T is set to 0 before either process begins execution and, as before, X is set to 5.


Now, how many different values of X are possible after both processes finish executing?
a) one
b) two
c) three
d) four
View Answer
Answer: a
Explanation: The semaphore T ensures that all the statements from A finish execution
before B begins. So now there is only one way in which statements from A and B can be
interleaved:
A1 A2 B1 B2: X = 11.

9. Semaphores are mostly used to implement ____________


a) System calls
b) IPC mechanisms
c) System protection
d) None of the mentioned
View Answer
Answer: b
Explanation: None.

10. Spinlocks are intended to provide __________ only.


a) Mutual Exclusion
b) Bounded Waiting
c) Aging
d) Progress
View Answer
Answer: b
Explanation: None.

This set of 1000+ Operating System MCQs focuses on “The Classic Synchronization
Problems”

1. The bounded buffer problem is also known as ____________


a) Readers – Writers problem
b) Dining – Philosophers problem
c) Producer – Consumer problem
d) None of the mentioned
View Answer
Answer: c
Explanation: None.

2. In the bounded buffer problem, there are the empty and full semaphores that
____________
a) count the number of empty and full buffers
b) count the number of empty and full memory spaces
c) count the number of empty and full queues
d) none of the mentioned
View Answer
Answer: a
Explanation: None.

3. In the bounded buffer problem ____________


a) there is only one buffer
b) there are n buffers ( n being greater than one but finite)
c) there are infinite buffers
d) the buffer size is bounded
View Answer
Answer: b
Explanation: None.

4. To ensure difficulties do not arise in the readers – writers problem _______ are given
exclusive access to the shared object.
a) readers
b) writers
c) readers and writers
d) none of the mentioned
View Answer
Answer: b
Explanation: None.

5. The dining – philosophers problem will occur in case of ____________


a) 5 philosophers and 5 chopsticks
b) 4 philosophers and 5 chopsticks
c) 3 philosophers and 5 chopsticks
d) 6 philosophers and 5 chopsticks
View Answer
Answer: a
Explanation: None.

6. A deadlock free solution to the dining philosophers problem ____________


a) necessarily eliminates the possibility of starvation
b) does not necessarily eliminate the possibility of starvation
c) eliminates any possibility of any kind of problem further
d) none of the mentioned
View Answer
Answer: b
Explanation: None.

7. All processes share a semaphore variable mutex, initialized to 1. Each process must
execute wait(mutex) before entering the critical section and signal(mutex) afterward.
Suppose a process executes in the following manner.
signal(mutex);
.....
critical section
.....
wait(mutex);

In this situation :
a) a deadlock will occur
b) processes will starve to enter critical section
c) several processes maybe executing in their critical section
d) all of the mentioned
View Answer
Answer: c
Explanation: None.

8. All processes share a semaphore variable mutex, initialized to 1. Each process must
execute wait(mutex) before entering the critical section and signal(mutex) afterward.
Suppose a process executes in the following manner.
wait(mutex);
.....
critical section
.....
wait(mutex);
a) a deadlock will occur
b) processes will starve to enter critical section
c) several processes maybe executing in their critical section
d) all of the mentioned
View Answer
Answer: a
Explanation: None.

9. Consider the methods used by processes P1 and P2 for accessing their critical sections
whenever needed, as given below. The initial values of shared boolean variables S1 and S2
are randomly assigned. (GATE 2010)

Method used by P1 :
while(S1==S2);
Critical section
S1 = S2;

Method used by P2 :
while(S1!=S2);
Critical section
S2 = not(S1);

Which of the following statements describes 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
View Answer
Answer: d
Explanation: None.

You might also like