Q: 1 The most common technique used for protecting a critical section in Linux is:
Critical lock protocol
Spinlock
Critical Spinning
Mutex interlocking
[ Option B ]
In Linux, a critical section is a part of the code that accesses shared resources, such as variables, files, or hardware, that must not be used by more than one process or thread at a time. To prevent data corruption or race conditions, Linux uses synchronization mechanisms to protect these critical sections. The most common technique used in the Linux kernel for this purpose is the spinlock.
A spinlock is a lightweight lock used in Linux to protect a critical section. It makes a process “spin” in a loop until it can enter the section, ensuring that only one process accesses the shared resource at a time without using heavy context switching.
Q: 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
Stack Overflow
Aging
Race Condition
Buffer Overflow
[ Option C ]
A Race Condition occurs when multiple processes or threads access and modify shared data concurrently, and the final outcome depends on the order in which the operations are executed. Since the execution order may vary, it can lead to inconsistent or unexpected results.
Q: 3 Which type of semaphore can be used to provide mutual exclusion when mutex locks are not available?
Counting semaphore
Binary semaphore
Timed semaphore
Spinlock
[ Option B ]
Semaphore is a synchronization tool used to control access to shared resources in concurrent systems. There are two types of semaphores:
Mutex locks are specialized locks for mutual exclusion, but if they are not available, a binary semaphore can perform the same function.
Q: 4 In order to allow only one process to enter its critical section, binary semaphore is initialised to
0
1
2
3
[ Option B ]
A binary semaphore is a synchronization mechanism that can take only two values, 0 or 1. It is used to control access to a critical section so that only one process can enter at a time.
When the semaphore is initialized to 1:
This ensures Mutual Exclusion, meaning only one process is in the critical section at any time. So, Binary semaphore acts like a lock (mutex (Mutual Exclusion)).
| Semaphore Type | Values | Use |
|---|---|---|
| Binary Semaphore. | 0 or 1 | Mutual exclusion. |
| Counting Semaphore. | 0 to n | Multiple resource access. |
Q: 5 A counting semaphore was initialized to 8. Then 12 P (wait) operations and 7 V (signal) operations were completed on this semaphore. The resulting value of semaphore is—
4
3
5
1
[ Option C ]
Thank you so much for taking the time to read my Computer Science MCQs section carefully. Your support and interest mean a lot, and I truly appreciate you being part of this journey. Stay connected for more insights and updates! If you'd like to explore more tutorials and insights, check out my YouTube channel.
Don’t forget to subscribe and stay connected for future updates.