NPTEL Operating System Fundamentals Week 7 Assignment Answers 2024

Sanket
By Sanket

NPTEL Operating System Fundamentals Week 7 Assignment Answers 2024

1. Assume that two processes P0 and P1 trying to safely access a shared resource without causing race conditions or data inconsistency. Here P0 and P1 share two variables: int turn, and boolean flag[2]. Consider the structure of the process P1 and then choose the correct option.


do
{
	flag[1] = true;
	turn = 0;
	while (flag[0] && turn ==0);
		critical section
	flag[1] = false;
		remainder section
}
while (true);

(A) The above solution only achieves the mutual exclusion property.
(B) The above solution only achieves the progress requirement property.
(C) The above solution achieves only bounded-waiting property.
(D) The above solution is correct for solving the critical section problem for four processes.
(E) The above solution achieves mutual exclusion, progress requirement, and bounded-waiting properties.

Answer :- For Answers Click Here 

2. Choose the correct statement.

(A) Busy waiting involves using special hardware instructions that make a process wait until access to a critical section is granted.
(B) Busy waiting occurs when a process continuously checks a condition in a loop, using CPU resources until the condition is met.
(C) Busy waiting is a software solution that eliminates the need for semaphores or mutexes in process synchronization.
(D) Busy waiting helps improve CPU utilization by allowing a process to continue executing while waiting for a resource.
(E) Busy waiting can be avoided by using priority inversion techniques.

Answer :- For Answers Click Here 

3. Choose the correct statement about test_and_set() instruction.

(A) It is a hardware-based solution that avoids busy waiting.
(B) it is used to implement spinlocks for mutual exclusion.
(C) It ensures that a process eventually enters its critical section.
(D) It can be used to release a lock once it is acquired.
(E) It is a process scheduling method.

Answer :- For Answers Click Here 

4. The compare_and_swap instruction ensures

(A) Only mutual exclusion.
(B) Only progress requirement.
(C) Only bounded-waiting.
(D) mutual exclusion, progress requirement, and bounded-waiting.
(E) fair process scheduling among two processes.

Answer :- 

5. Choose the correct statement.

(A) wait() increments the semaphore value, while signal() decrements it.
(B) wait() decrements the semaphore value and may block a process if the value becomes negative.
(C) signal() decrements the semaphore value, and wait() increments it.
(D) signal()blocks a process until wait() is called.
(E) Both wait() and signal() are used to implement busy waiting.

Answer :- 

6. Choose the correct option for the counting semaphore.

(A) Counting semaphores can be used to provide mutual exclusion.
(B) Counting semaphores can be used to control access to a given resource consisting of infinite instances.
(C) A Counting semaphore allows multiple processes to enter the critical section simultaneously, up to a maximum limit.
(D) Counting semaphore is a semaphore that never needs initialization.
(E) Counting semaphore is used exclusively in binary locking mechanisms.

Answer :- For Answers Click Here 

7. Choose the correct statement in the Bounded-Buffer (Producer-Consumer) problem context.

(A) The buffer size determines the maximum number of items the producer can produce.
(B) If the buffer is full, the consumer is forced to wait until the producer produces more items.
(C) The producer must check if the buffer is full before adding an item to the buffer.
(D) The buffer size does not affect the synchronization between the producer and consumer.
(E) The consumer can consume items from the buffer even when empty.

Answer :- 

8. Assume that we have two processes, P1 and P2. Consider the following pseudocode. Here semaphore S1 = 1; semaphore S2 = 0.

image 19

(A) It will execute the process in the sequence P1P2P1P2P1P2….
(B) It will execute the process in the sequence P2P1P2P1P2P1….
(C) It will execute the process in the sequence P1P2P2P1P2P2….
(D) It will execute the process in the sequence P2P1P1P2P1P1….
(E) It will execute the process in the sequence P1P1P2P2P1P1P2P2….

Answer :- 

9. Consider the following code snippets involving two processes, P1 and P2, that use wait() and signal() operations on two semaphores, S1 and S2, both initialized to 1. Which of the following scenarios can lead to a deadlock?

image 20

(A) If P1 executes wait(S1) first, and P2 executes wait(S2) first.
(B) If both P1 and P2 execute wait(S1) first.
(C) If both P1 and P2 execute wait(S2) first.
(D) If P1 executes wait(S1) first, and P2 executes wait(S1) first.
(E) If P1 executes signal(S1) first, and P2 executes signal(S2) first.

Answer :- 

10. Consider a system with two low-priority processes, P and Q, and one high-priority process, R. Semaphores S1 and S2 are initialized to 1.

image 21

Which of the following statements best describes a scenario involving priority inversion and deadlock?

(A) P and Q will always run before H because they have higher priority.
(B) R may experience priority inversion if it gets blocked by P or Q, but does not lead to a deadlock.
(C) R may experience priority inversion if P and Q both run and hold semaphores S1 and S2, respectively, leading to a situation where R is blocked, and it may also lead to a deadlock.
(D) The system will not experience priority inversion or deadlock because semaphores are initialized to 1.
(E) R never experiences priority inversion.

Answer :- For Answers Click Here 
Share This Article
Leave a comment