Operating System

21. Consider a system with seven processes A through G and six resources R through W. Resource ownership is as follows: process A holds R and wants T, process B holds nothing but wants T, process C holds nothing but wants S, process D holds U and wants S & T, process E holds T and wants S, process F holds W and wants S, process G holds V and wants U. Is the system deadlocked? If yes, ............... processes are deadlocked.
मान लें किसी system में A से G तक सात processes और R से W तक छह resources हैं। Resource ownership दिया गया है। क्या system deadlocked है? यदि हाँ, तो कौन-से processes deadlocked हैं?
(UGC NET C.S. August-2016 (Paper-II))
A. No
B. Yes, A, B, C
C. Yes, D, E, G
D. Yes, A, B, F

Correct Answer: C

Explanation (EN): The system is deadlocked due to processes D, E, and G.

Explanation (HI): System में D, E और G processes के कारण deadlock है।

22. Suppose there are four processes in execution with 12 instances of a Resource R in a system. The maximum need of each process and current allocation are given below. With reference to current allocation, is system safe? If so, what is the safe sequence?
मान लें किसी system में Resource R की 12 instances हैं और चार processes execute हो रही हैं। प्रत्येक process की maximum need और current allocation दिए गए हैं। Current allocation के आधार पर क्या system safe है? यदि हाँ, तो safe sequence क्या है?
(UGC NET C.S. June-2016 (Paper-II))
A. No
B. Yes, P1 P2 P3 P4
C. Yes, P4 P3 P1 P2
D. Yes, P2 P1 P3 P4

Correct Answer: C

Explanation (EN): Remaining need is P1=5, P2=5, P3=3, P4=2 and available resources are 2. First P4 can finish, then P3, then P1, and finally P2. Hence the safe sequence is P4, P3, P1, P2.

Explanation (HI): Remaining need P1=5, P2=5, P3=3, P4=2 है और available resources 2 हैं। पहले P4 finish कर सकता है, फिर P3, उसके बाद P1 और अंत में P2। इसलिए safe sequence P4, P3, P1, P2 है।

23. A computer system has 7 tape drives. There 'n' processes competing for them. Each process may need 2 tape drives. What is the maximum value of 'n' for which the system is guaranteed to be deadlock free?
एक computer system में 7 tape drives हैं। उनके लिए 'n' processes compete कर रही हैं। प्रत्येक process को 2 tape drives की आवश्यकता हो सकती है। 'n' का अधिकतम मान क्या होगा ताकि system guaranteed deadlock free रहे?
(DSSSB TGT C.S. 07.08.2021 (Shift-I))
A. 2
B. 3
C. 4
D. 1

Correct Answer: B

Explanation (EN): Each process may need at most 2 drives. To guarantee deadlock freedom, the system must always be able to satisfy at least one process completely. Thus 2n ≤ 7, so n ≤ 3.

Explanation (HI): प्रत्येक process को अधिकतम 2 drives चाहिए। Deadlock freedom की guarantee के लिए system को कम-से-कम एक process की पूरी आवश्यकता हमेशा पूरी करने योग्य होना चाहिए। इसलिए 2n ≤ 7, अतः n ≤ 3।

24. In context of semaphores choose the option with valid codes for wait() and signal() functions:
Semaphores के संदर्भ में wait() और signal() functions के valid code वाला विकल्प चुनिए।
(HTET PGT C.S. 2022)
A. Wait (s) { while (s) <= 0; s++; } and signal (s) { s--; }
B. Wait (s) { while (s) <= 0; s--; } and signal (s) { s++; }
C. Wait (s) { s--; } and signal (s) { while (s) <= 0; s++; }
D. Wait (s) { s++; } and signal (s) { while (s) <= 0; s--; }

Correct Answer: B

Explanation (EN): In semaphore operations, wait() decrements the semaphore after checking availability, and signal() increments the semaphore. Therefore option (b) gives the valid code.

Explanation (HI): Semaphore operations में wait() उपलब्धता जाँचने के बाद semaphore की value घटाता है और signal() उसकी value बढ़ाता है। इसलिए option (b) सही code देता है।

25. Which of the following is not a valid deadlock prevention scheme?
निम्न में से कौन-सी valid deadlock prevention scheme नहीं है?
(HTET PGT C.S. 2020)
A. Release all resources before requesting a new resource.
B. Number the resources uniquely and never request a lower numbered resource than the last one requested.
C. Never request a resource after releasing any resource.
D. Request and all required resources be allocated before execution.

Correct Answer: C

Explanation (EN): Options (a), (b), and (d) are valid deadlock prevention methods because they break necessary deadlock conditions. Option (c) is not a standard deadlock prevention scheme.

Explanation (HI): Options (a), (b) और (d) deadlock prevention की valid methods हैं क्योंकि ये deadlock की आवश्यक conditions को तोड़ती हैं। Option (c) कोई standard deadlock prevention scheme नहीं है।

26. Which of the following is not related to synchronization in Operating System?
निम्न में से कौन-सा Operating System में synchronization से संबंधित नहीं है?
(HTET PGT C.S. 2019)
A. Bounded Buffer problem
B. Readers-Writers problem
C. Dining Philosophers problem
D. Belady's Anomaly

Correct Answer: D

Explanation (EN): Bounded Buffer, Readers-Writers, and Dining Philosophers are classic synchronization problems. Belady's Anomaly is related to page replacement, not synchronization.

Explanation (HI): Bounded Buffer, Readers-Writers और Dining Philosophers classic synchronization problems हैं। Belady's Anomaly page replacement से संबंधित है, synchronization से नहीं।

27. Which of the following is not required condition for a deadlock?
निम्न में से कौन-सी deadlock के लिए आवश्यक condition नहीं है?
(HTET PGT C.S. 2018)
A. Hold and Wait
B. Preemptive
C. Mutual Exclusion
D. Cycle

Correct Answer: B

Explanation (EN): The required conditions for deadlock are mutual exclusion, hold and wait, no preemption, and circular wait. Therefore preemptive is not required.

Explanation (HI): Deadlock की आवश्यक conditions हैं mutual exclusion, hold and wait, no preemption, और circular wait। इसलिए preemptive आवश्यक condition नहीं है।

28. For each thread of a multi-threaded process, there is a separate:
Multi-threaded process के प्रत्येक thread के लिए अलग क्या होता है?
(CGPSC C.S. 2020 Set-A)
A. Process control block
B. User address space
C. User and kernel stack
D. Kernel space only

Correct Answer: C

Explanation (EN): All threads of a process share code, data, files, and address space, but each thread has its own user and kernel stack.

Explanation (HI): किसी process के सभी threads code, data, files और address space share करते हैं, लेकिन प्रत्येक thread का अपना अलग user और kernel stack होता है।

29. Semaphore are used to solve the problem of:
Semaphores का उपयोग किस problem को solve करने के लिए किया जाता है?
(CGPSC C.S. 2020 Set-A)
A. Race condition
B. Multi-tasking
C. Mutual exclusion
D. Both (A) and (C)

Correct Answer: C

Explanation (EN): As per the given answer key, semaphores are used for mutual exclusion, i.e. ensuring that only one process/thread accesses the critical section at a time.

Explanation (HI): दिए गए answer key के अनुसार semaphores का उपयोग mutual exclusion के लिए किया जाता है, अर्थात एक समय में केवल एक process/thread critical section में प्रवेश करे।

30. The advantage of having multiple threads over multiple processes is: (i) Less time for creation (ii) Less time for termination (iii) Less time for switching (iv) Kernel not involved in communication among threads
Multiple processes की तुलना में multiple threads के advantages क्या हैं? (i) Creation में कम समय (ii) Termination में कम समय (iii) Switching में कम समय (iv) Threads के बीच communication में kernel शामिल नहीं होता
(CGPSC C.S. 2020 Set-A)
A. (i), (ii), (iii)
B. (i), (ii), (iv)
C. (ii), (iii), (iv)
D. (i), (ii), (iii), (iv)

Correct Answer: D

Explanation (EN): Threads are lighter than processes. They require less time for creation, termination, and switching, and communication among threads is more efficient as they share the same address space.

Explanation (HI): Threads, processes की तुलना में हल्के होते हैं। इन्हें बनाने, समाप्त करने और switch करने में कम समय लगता है, तथा threads के बीच communication अधिक efficient होता है क्योंकि वे same address space share करते हैं।