Javatpoint Logo
Javatpoint Logo

COMPUTER SCIENCE QUIZ - I: Part 2

TOPIC - 2 OPERATING SYSTEM

Q. 1 Which of the following characteristics best describes an OS that is multi-programmed?

  1. More than one program may be loaded simultaneously into the main memory.
  2. A subsequent program is scheduled right away if one is waiting for a specific event.
  3. If a program's execution is interrupted, another one is instantly scheduled.
  1. I and II only
  2. II and III only
  3. I only
  4. I, II and III

Ans. (d) I, II, and III

Explanation: An OS is responsible for process management, memory management, file management, security, error detection and many more. The following statements are one of the main characteristics of OS. The first statement refers to multiprogramming, the second statement refers to context switch and third statement refers to the error detection and correction.


Q. 2 Assume that there are consistently some processes in the ready state in the following process state transition diagram for a uniprocessor system:

COMPUTER SCIENCE QUIZ - I: Part 2

Now take into account the following assertions:

  1. When one process makes transition D, another process instantly makes transition A.
  2. While another process P1 is in the running state, a process P2 in the blocked state, can complete the transition E.
  3. Preemptive scheduling is used by the OS.
  4. Non-preemptive scheduling is used by the OS.

Which of the aforementioned statements is/are TRUE?

  1. I and II
  2. II and III
  3. III and IV
  4. I and IV

Ans. (b) II and III

Explanation: Statement 1 says, "when one process makes transition D, another process instantly makes transition A" which is not true because transition A does not depend on any other transitions. Whenever a process comes in the start state, it instantly makes the transition A and waits in the ready state for its turn.

Statement 2 says, "While another process P1 is in the running state, a process P2 in the blocked state, can complete the transition E", which is absolutely true.

Statement 3 says, "Preemptive scheduling is used by the OS" which is true because a process in the running state can be preempted by the OS anytime as we have a transition F to represent the same.

Statement 4 is false, as statement 3 is true.


Q. 3 A computer manages a variety of interrupt sources, of which the following are pertinent to this query.

  1. Disruption from the CPU's temperature sensor (raises interrupt if CPU temperature is too high)
  2. Interruption by a mouse (raises interrupt if the mouse is moved or a button is pressed)
  3. Keyboard Interruption (raises interrupt when a key is pressed or released)
  4. Hard disc interruption (raises interrupt when a disc read is completed)

Which of these will be given the UPPER MOST priority treatment?

  1. Interruptions from the CPU Temperature Sensor
  2. Interruptions from the Mouse
  3. Interruptions from the Keyboard
  4. Interruptions from the Hard Disks

Ans. (a) Interruptions from the CPU Temperature Sensor

Explanation:

The computer is totally dependent on the CPU if the collapse, the whole computer will also become inoperable. The highest priority is given to the interruptions from the CPU then the interruptions from the other components of the computer.


Q. 4 According to how long a process has been waiting, a scheduling algorithm determines its priority. Each and every process begins with priority 0 (the lowest priority). Every T time unit, the scheduler reviews the process priorities and selects the subsequent process to schedule. Which of the following statements applies if there are no I/O activities and everyone arrives at the same time?

  1. The first-come, first-served algorithm is the same as this one.
  2. The round-robin algorithm is the same as this one.
  3. This process is an exact replica of the shortest-job-first process.
  4. This method is a substitute for the shortest-remaining-time-first method.

Ans. (b) The round-robin algorithm is the same as this one

Explanation: The round-robin algorithm can be implemented based on the given idea. The time 'T' is the quantum period, and for every 'T' time unit, the algorithm determines the priority and schedules the process accordingly. Hence, (b) is the correct answer.


Q. 5 Consider a round-robin CPU sharing scenario with n processes. What must be the quantum size q in order to minimize the overhead caused by process switching while still ensuring that every process receives a turn at the CPU at least every t seconds, assuming that each process switch takes s seconds?

  1. q ≤ (t ? ns) / (n ? 1)
  2. q ≥ (t ? ns) / (n ? 1)
  3. q ≤ (t ? ns) / (n + 1)
  4. q ≥ (t ? ns) / (n + 1)

Ans. (a) q ≤ (t?ns)/(n?1)

Explanation:

Each process receives CPU time for q seconds before requesting CPU time once more after t seconds.

As a result, (n-1) processes will run once the current process has access to the CPU once more. For context switching, each process needs s seconds.

P1 cs P2 cs P3 cs ........ Pn cs P1
q s q s q s ........ q s q

Where cs -> Context Switching

As can be observed, n context switches and (n-1) processes have occurred since P1 left and returned. Equation will be as follows:

q(n-1) + s(n) <= t

q(n-1) + ns <= t

q(n-1) <= t - ns

q <= (t - ns) / (n -1)

Hence, (a) is the correct answer.


Q. 6 Which of the subsequent statements is accurate?

  1. Scheduling using the shortest remaining time first may result in starvation
  2. Preemptive scheduling could result in starvation
  3. When it comes to reaction time, round robin outperforms FCFS.
  1. 1 and 2 only
  2. 2 and 3 only
  3. 1 only
  4. All the above

Ans. (d) All the above

Explanation:

I - "Scheduling using the shortest remaining time first may result in starvation" which is true because the process requiring more time may starve because of other processes requiring less time.

II - "Preemptive scheduling could result in starvation", which is also true. As the name suggests, any process can be preempted at any time, and starvation may occur.

III - "When it comes to reaction time, round robin outperforms FCFS", which is also true.

Reaction time or Response time is the amount of time taken when a process first receives the CPU after entering the ready state. The reaction time in round-robin is very less compared to FCFS.


Q. 7 Which of the following scheduling algorithms is/are starvation free?

  1. First-Come First-Serve (FCFS)
  2. Round-Robin (RR)
  3. Shortest Job First
  4. Shortest Remaining Time First
  5. Priority Based
  1. III, IV and V
  2. I, II and III
  3. I and II
  4. I only

Ans. (c) I and II.

Explanation:

FCFS and Round-Robin are starvation-free scheduling algorithms, and SJF, SRTF, and Priority based scheduling algorithms may cause starvation.


Q. 8 The two-level CPU scheduling is frequently used for the following reasons:

  1. It is employed when available memory is insufficient to accommodate all running programs.
  2. Because it performs similarly to the FIFO.
  3. As a result of its facilitation of retrieving a collection of procedures from memory and making a decision based on them.
  4. Because it prevents adjusting the group of in-core processes.

Which statement is/are accurate?

  1. I and II
  2. I, II, and IV
  3. II and IV
  4. I and III

Ans. (d) I and III

Explanation: When memory is insufficient to contain all the ready processes, the two-level CPU scheduling is utilized because it makes it easier to load a selection of processes into memory and make a decision from there.

Hence, Option (d) is the correct answer.


Q. 10 What is not true about the Multi-Level Feedback Queue processor scheduling algorithm?

  1. The priorities of queues vary.
  2. There could be various scheduling algorithms for each queue.
  3. Processes are permanently assigned to a queue.
  4. This method can be modified to fit a particular system that is being developed.

Ans. (c) Processes are permanently assigned to a queue.

Explanation: Multilevel Feedback Queues Scheduling (MLFQ) is similar to Multilevel Queue (MLQ) Scheduling. It allows processes to move between queues. Consequently, it is a lot more effective than multilevel queue scheduling. One process cannot stay in a particular queue permanently.


Q. 11 Which of the following statements is true regarding a crucial section problem solution?

  1. No assumptions should be made regarding CPU counts or speed.
  2. There cannot be two processes running at once inside of their critical sections.
  3. Processes that aren't in its critical part could obstruct others.
  4. If the bounded wait is satisfied, processes do not wait indefinitely to enter their crucial phase.

Ans. (c) Processes that aren't in its critical part could obstruct others.


Explanation:

Only one process is allowed to enter the critical section at a time. Hence, (c) is the correct answer.

Q. 12 The following strategies are those employed by processes P1 and P2 to gain access to their critical section at any time. S1 and S2 are two shared Boolean variables, that are given random initial values.

P1 P2
While (S1 == S2); While (S1 != S2);
// Critical Section // Critical Section
S1 = S2; S1 != S2;

The properties attained are best described by which of the following statements?

  1. Mutual Exclusion but not Progress
  2. Progress but not Mutual Exclusion
  3. Both Mutual Exclusion and Progress
  4. Neither Mutual Exclusion nor Progress

Ans. (a) Mutual Exclusion but not Progress

Explanation:

Two variables, S1 and S2, can be either equal or not equal at a time.

Process P1 enters its critical section when S1 is not equal to S2 (S1 != S2), and Process P2 enters its critical section when S1 and S2 are equal (S1 == S2).

So, only one process, either P1 or P2, can enter their critical section at a time. This satisfies the Mutual Exclusion Property.

After executing the critical section, P1 makes S1 equal to S2 and allows P2 to execute its critical section, and P2 makes S1 not equal to S2 and allows P1 to executes its critical section irrespective of their values. We can clearly see that there are dependencies between both the processes and strict alternation between them. This violates the property of Progress.

Hence, (a) is the correct answer.


Q. 13 The code segments that are executed by the three concurrent processes X, Y, and Z each access and modify a distinct shared variable. Before accessing the corresponding code segments, processes X, Y, and Z do the P operation (i.e., wait) on semaphores a, b, and c; Y performs the P operation on semaphores c, d, and a; and Z performs the P operation on semaphores c, d, and a. Each process calls the V operation (also known as a signal) on each of its three semaphores after finishing the execution of its code segment. All semaphores are binary semaphores that have an initial value of 1. Which of the following best describes the processes' order of invoking the P operations without causing a deadlock?

  1. X: P(a)P(b)P(c) Y: P(b)P(c)P(d) Z: P(c)P(d)P(a)
  2. X: P(a)P(b)P(c) Y: P(b)P(c)P(d) Z: P(c)P(d)P(a)
  3. X: P(b)P(a)P(c) Y: P(c)P(b)P(d) Z: P(a)P(c)P(d)
  4. X: P(a)P(b)P(c) Y: P(c)P(b)P(d) Z: P(c)P(d)P(a)

Ans. (b) X: P(a)P(b)P(c) Y: P(b)P(c)P(d) Z: P(c)P(d)P(a)

Explanation: To solve this problem, we have to analyze each option. We will be trying to achieve deadlock, and if we found, then we will move to the next option. Here, we have to note that there can be different orders of executions between X, Y, and Z and context switch can happen at any point in time.

Analyzing option (a):

a = 1, b = 1, c = 1

Step 1 - Process X starts its execution and performs the P operation on a (a = 0, b = 1, and c = 1).

Step 2 - We context-switched the execution, and Y gets the chance to execute.

Step 3 - Process Y starts its execution and performs P operation on b (a = 0, b = 0, and c = 1).

Step 4 - We context-switched the execution, and Z gets the chance to execute.

Step 5 - Process Y starts its execution and performs the P operation on b (a = 0, b = 0, and c = 0).

Step 6 - Here, the values of all the semaphores a, b, and c are zero and no process can perform wait operations on any of these semaphores. Hence, deadlock occurs.

As there is a possibility of occurring deadlock. So, (a) is not a correct option.

Analyzing option (b):

Option (b) is the correct answer. Any possible orders of execution are deadlock-free in this case. You can analyze this option on your own.

Analyzing option (c):

Step 1 - Say process Y performs the P operation on c => c = 0

Step 2 - Context-switch happened, and process Z performs the P operation on a => a = 0

Step 3 - Context-switch happened, and process x performs the P operation on b => b = 0

Here also, the values of all the semaphores a, b, and c are zero, and no process can perform wait operations on any of these semaphores. Hence, a deadlock occurs.

As there is a possibility of a deadlock. So, (c) is not the correct option.

Analyzing option (d):

Step 1 - Say Process Z gets the chance and performs the P operation on c => c = 0.

Step 2 - Context-switched happened, and process Y gets the chance but it could not perform the wait operation on c as c is already 0.

Step 3 - Process X gets the chance and performs the P operations on a and b => a = 0 and b = 0. But cannot perform on c.

Here also, the values of all the semaphores a, b, and c are zero, and no process can perform wait operations on any of these semaphores. Hence, a deadlock occurs.

As there is a possibility of a deadlock. So, (d) is not the correct option.


Q. 14 The Dining Philosophers Problem can be resolved in a way that prevents deadlock by:

  1. Making sure that everyone chooses the left fork before the right one.
  2. Making sure that everyone chooses the right fork before choosing the left.
  3. Making sure that one philosopher takes the left fork before the right fork and that everyone else takes the right fork before the left fork.
  4. None of these

Ans. (c) The Dining Philosophers Problem can be resolved in a way that prevents deadlock by Making sure that one philosopher takes the left fork before the right fork and that everyone else takes the right fork before the left fork.


Q. 15 The value of a counting semaphore at a specific computation time is 10. Then, this semaphore was subjected to 12 P operations and "x" V operations. If the semaphore's final value is 7, x will have a value of

  1. 8
  2. 9
  3. 10
  4. 11

Ans. (b) 9

Explanation: The initial value of the counting semaphore was 10 then 12 P operations was performed:

result = 10 - 12

Then 'x' V operations were performed:

result = 10 - 12 + x ...(i)

and given

result = 7 ... (ii)

from (i) and (ii)

10 - 12 + x = 7

x - 2 = 7 => x = 7 + 2

x = 9

Hence, (b) is the correct answer.


Q. 16 A process must release all available resources before requesting access to any additional resources, according to some operating system policy. Choose the one that is TRUE out of the following:

  1. The policy is both starvation free and deadlock-free
  2. The policy is starvation free but not deadlock free
  3. The policy is deadlock free but not starvation free
  4. The policy is neither deadlock free nor starvation free.

Ans. (c) The policy is deadlock free but not starvation free

Explanation:

The above policy implemented by the operating system is deadlock free but not starvation free. The resource can not be hold by any process for a long time this ensures that the deadlock will never occur but this not guarantees bounded wait. Hence, some process may starve.


Q. 17 The following rules should be taken into consideration to avoid deadlock in a system with mutually exclusive resources.

  1. The process should gather all of its resources before starting to operate. All resources obtained up to that point are released if any resource is unavailable.
  2. Each resource has a unique number, and processes are only permitted to request resources in decreasing order of resource numbers.
  3. Each resource has a unique number, and processes are only permitted to request resources in decreasing order of resource numbers.
  4. Each resource has a distinct number. A process can only seek resources for those that are more numerous than the resources it already has.

Which of the aforementioned policies can be applied to avoid deadlock?

  1. Any one of I and III but not II and IV
  2. Any one of II and II but not I and IV
  3. Any one of the I, II and III but not IV
  4. Any one of the I, II, III, and IV

Ans. (d) Any one of the I, II, III, and IV

Explanation:

All of the above methods can be used to prevent deadlock.


Q. 18 Consider five processes sharing 11 instances of the same resource type in a system. A maximum of K instances can be requested by each process. Only one instance of the resource can be requested and released at once. The highest value of K that will never result in a deadlock is

  1. 2
  2. 3
  3. 4
  4. 5

Ans. (b) 3

Explanation:

When K = 2:

In the worst case each process will hold one instance of the resource and wait for the other one.

Total Resource = 11

Allocated = 5 * 1 = 5

Available = 11 - 5 = 6

Here, we have enough instances to full fill the requirements of all the processes. Hence, K = 2 can be a possible value.

When K = 3:

In the worst case each process will hold two instances of the resource and wait for the remaining one.

Total Resource = 11

Allocated = 5 * 2 = 10

Available = 11 - 10 = 1

Here, all the processes are requesting one more instance of the resource, and luckily, we have that one. We can full fill the requirement of one of the processes. After executing, the process will release the resource and other process will take advantage of that.

So, K = 3 can be maximum possible value.

When K = 4:

Here also, three processes acquire three-three instances of the resource and one process acquire two instances of the resource and process gets nothing.

Total Resource = 11

Available = 11 - 3 * 3 - 1 * 2 = 11 - 11 = 0

Here, all the processes will wait for other processes to release the resource which satisfies the condition of hold and wait resulting in deadlock.

Hence, (b) is the correct answer.


Q. 19 Which of the following statements about deadlock avoidance and prevention strategies is FALSE?

  1. If the resultant state is safe, the request for resources is always granted in deadlock prevention.
  2. If the resultant state is safe, the request for resources is always granted in deadlock avoidance.
  3. Avoiding deadlocks is less restricted than preventing them.
  4. Understanding the resources needed in advance is necessary for deadlock avoidance.

Ans. (a)

Explanation - The request for resources is granted if the resultant state is safe in deadlock avoidance method not is deadlock prevention method.


Q. 20 If the operating system supports __________, it is still feasible to run a program even if its size exceeds the RAM currently available on a computer.

  1. Virtual Memory
  2. Paging System
  3. Multitasking
  4. None of these

Ans. (b) Virtual Memory

Explanation: With the help of virtual memory, it is possible to run a program with size greater than the available memory.








Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA