Introduction To Operating Systems NPTEL Week 7 Assignment

Session: JULY-DEC 2023

Course Name: Introduction to Operating Systems

Course Link: Click Here

These are Introduction to Operating Systems NPTEL Assignment 7 Answers


Q1. State true or false.
A program to compute the sum of first 10,000 numbers can be divided into 4 sub parts and executed on 4 CPUs using either fork or threads. The reason why we prefer threads is because large portions of the data/code between the 4 sub-parts are very similar and need not be duplicated.

true
false.

Answer: true


Q2. Which of the following is false about User threads?
User threads can switch fast since it does not involve kernel.
User threads are lightweight since they do not require system calls.
Kernel is not aware of the behavior of every user threads i.e. if it is blocking or runnable.
None of these

Answer: None of these


Q3. Suppose we want to synchronize two concurrent process P and Q using binary semaphore S and T.
Process P: Process Q:
while(1){ while(1){
W: Y:
print ‘0’; print ‘1’;
print ‘0’; print ‘1’;
X: Z:
}
Synchronization statements can be inserted only at points W,X,Y,Z. Which of the following can lead to an output starting with ‘00110011’?

W : P(S) X : V(S) Y : P(T) Z: V(T) and initially S = T= 1
W : P(S) X : V(T) Y : P(T) Z: V(S) and initially S = 1 and T= 0
W : P(S) X : V(T) Y : P(T) Z: V(S) and initially S = T= 1
W : P(S) X : V(S) Y : P(T) Z: V(T) and initially S = 1 and T= 0

Answer: W : P(S)  X : V(T)  Y : P(T)  Z: V(S) and initially S = 1 and T= 0


These are Introduction to Operating Systems NPTEL Assignment 7 Answers


Q4. Each process Pi where i = 1 … 9 is given as follows
pi: Repeat p10: Repeat
P(Mutex) V(Mutex)
// Critical section //critical section
V(mutex) V(mutex)
What is the largest number of process that can be inside the critical section

1
2
3
None of these

Answer: None of these


Q5. Which of the following is not valid for deadlock prevention scheme?
Release all resource before requesting a new resource
Number all resources uniquely and never request a lower numbered resource than the last one requested
Never request a resource after releasing any resource
Request and allocate all required resource before execution.

Answer: Never request a resource after releasing any resource


Q6. An OS implements a policy that requires a process to release all resources before making a request for another resource. Which of the following is true based on above statement?
Both starvation and deadlock can occur
Starvation can occur but deadlock cannot occur
Starvation cannot occur, but deadlock can occur
Neither starvation nor deadlock occur.

Answer: Starvation can occur but deadlock cannot occur


These are Introduction to Operating Systems NPTEL Assignment 7 Answers


Q7. State True/ False
The following resource allocation leads to deadlock

True
False

Answer: False


Q8. Consider a situation with the dining philosopher’s problem having 5 philosophers. What is the minimum number of forks required to prevent a deadlock?
5
6
10
None of these

Answer: 6


Q9. State True/False
In dining philosopher problem (with N philosophers), all the even numbered philosophers takes the left fork first and then the right fork and all the odd numbered philosopher takes the right fork first and then the left fork. This arrangement will prevent deadlock.

True
False

Answer: True


These are Introduction to Operating Systems NPTEL Assignment 7 Answers


Q10. State true or false.
a. Deadlock detection is possible using the allocation and request matrices alone.
b. A way to recover from deadlock is to take away the resource from one of the processes or to kill the process itself.
c. Banker’s algorithm is used to detect deadlocks by analyzing the unsafe states.

True, True, False
False, True, True
True, False, True
False, True, False

Answer: True, True, False


Q11. Which one of the following is FALSE?
User level threads are not scheduled by the kernel.
When a user level thread is blocked, all other threads of its process are blocked.
Context switching between user level threads is faster than context switching between kernel level threads.
Kernel level threads cannot share the code segment

Answer: Kernel level threads cannot share the code segment


Q12. Consider a system has 3 process P1, P2, P3. Process P1 needs 20 units of resource R, P2 needs 15 units of R and P3 needs 5 unit of R. What is the maximum unit of resource R that leads to deadlock?
3
20
35
37

Answer: 37


These are Introduction to Operating Systems NPTEL Assignment 7 Answers


Q13. A system has 5 process and 3 resources (A, B, C). The maximum count of resources are (10, 5, 7). Consider the following table of resource allocation.
State True/False
The above resource allocation leads to deadlock

True
False

Answer: False


Q14. Which one these is a safe sequence in Question 13?
P1, P3, P4 , P0, P2 only
P2, P4, P3, P1, P0 only
Both a and b
None are safe sequences

Answer: P1, P3, P4 , P0, P2 only


Q15. In a non-multiprogramming OS, a deadlock could occur
When two processes share the same resource
Can never happen
When two processes run at the same time, waiting for resources held by each other
When an interrupt occurs

Answer: Can never happen


These are Introduction to Operating Systems NPTEL Assignment 7 Answers

More Weeks of Introduction to Operating Systems: Click here

More Nptel Courses: Click here


These are Introduction to Operating Systems NPTEL Assignment 7 Answers

Course Name: Introduction To Operating Systems

Link of course: Click here


Consider a system with the above resource allocation. Answer the question 1 and 2 based on this graph.

Q1) The safe sequence of execution for the process in the above figure is
a. p3, p1, p2, p4
b. p2, p1, p4, p3
c. p3, p1, p4, p2
d. Deadlock occurs

Answer: b. p2, p1, p4, p3


These are Introduction to Operating Systems NPTEL Assignment 7 Answers


Q2) Consider a situation with the dining philosopher’s problem having n philosophers. What is the minimum number of forks required to prevent a deadlock?
a. n-1
b. n
c. n+1
d. 2n

Answer: c. n+1


A system has 5 process and 3 resources (A, B, C). The maximum count of resources are (10, 5, 7). Consider the following table of resource allocation.

These are Introduction to Operating Systems NPTEL Assignment 7 Answers

Q3) The above allocation result in unsafe state of the process.
a. True
b. False

Answer: b. False


These are Introduction to Operating Systems NPTEL Assignment 7 Answers


Q4) Consider P1 has made a request of (1,0,2), then what will be a safe sequence?
a. P1, P2, P3, P4, P0
b. P1, P3, P0, P4, P2
c. P1, P3, P4, P0, P2
d. Unsafe sequence

Answer: c. P1, P3, P4, P0, P2


These are Introduction to Operating Systems NPTEL Assignment 7 Answers


Q5) Consider a system with 6 processes, where each process needs 2 copies of Resource R. The maximum units of R required to cause deadlock is _________.

Answer: 6


Q6) Consider a system with 6 processes, where each process needs 2 copies of Resource R.The minimum units of R for deadlock free is ________.

Answer: 7


These are Introduction to Operating Systems NPTEL Assignment 7 Answers


Each process Pi where i = 1 … 9 is given as follows
pi: Repeat p10 : Repeat
P(Mutex) V(Mutex)
// Critical section //critical section
V(mutex) V(mutex)

Q7) What is the largest number of processes that can be inside the critical section
a. 10
b. 0
c. 3
d. None of these

Answer: a. 10


These are Introduction to Operating Systems NPTEL Assignment 7 Answers


Q8) Consider a system has 3 process P1, P2, and P3. Process P1 needs 11 units of resource R; Process P2 needs 21 units of R and Process P3 needs 16 unit of R. What is the maximum unit of resource R that leads to deadlock?

Answer: 45


These are Introduction to Operating Systems NPTEL Assignment 7 Answers


Q9) Which of the following is false about User User threads?
a. User threads can switch fast since it does involve kernel.
b. User threads are lightweight since they do not require system calls.
c. Kernel is not aware of the behavior of every user threads i.e. if it is blocking or runnable.
d. None of these

Answer: d. None of these


These are Introduction to Operating Systems NPTEL Assignment 7 Answers


Q10) Suppose we want to synchronize two concurrent processes P and Q using binary semaphores S and T.
Synchronization statements can be inserted only at points W,X,Y,Z. Which of the following can lead to an output starting with ‘00110011’?

a. W : P(S) X : V(S) Y : P(T) Z : V(T) and initially S = T = 1
b. W : P(S) X : V(T) Y : P(T) Z : V(S) and initially S = 1 and T=0
c. W : P(S) X : V(T) Y : P(T) Z : V(S) and initially S = T = 1
d. W : P(S) X : V(S) Y : P(T) Z : V(T) and initially S = 1 and T = 0

Answer: b. W : P(S) X : V(T) Y : P(T) Z : V(S) and initially S = 1 and T=0


These are Introduction to Operating Systems NPTEL Assignment 7 Answers

All weeks of Introduction To Operating Systems: https://progies.in/answers/nptel/introduction-to-operating-systems

More NPTEL Solutions: https://progies.in/answers/nptel


These are Introduction to Operating Systems NPTEL Assignment 7 Answers
The content uploaded on this website is for reference purposes only. Please do it yourself first.