What is the main purpose of a critical section in process synchronization?
To allocate CPU time efficiently
To protect shared resources from concurrent access
To ensure processes execute in a specific order
To handle process priorities
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
In Peterson's solution for the critical section problem, which of the following conditions ensures that the critical section is mutually exclusive?
Checking and setting the turn variable
Busy waiting on the flag array
Using semaphores for synchronization
Setting priority levels for processes
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
Which of the following is a characteristic of the Test-and-Set Lock (TSL) instruction?
It requires no hardware support
It is prone to starvation
It does not guarantee mutual exclusion
It can be used in both user and kernel modes
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
Starvation in process synchronization occurs when:
A low-priority process is never allocated the CPU
A high-priority process is preempted repeatedly.
A process waits indefinitely due to a logical error
All processes are blocked indefinitely
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
Which semaphore operation is most likely to lead to deadlock if not used carefully?
Initialization
P (wait)
V (signal)
None of the above
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
Which of the following statements correctly describes the behavior of the code given below?

int flag[2];

int turn;

void process0() {

flag[0] = 1;

turn = 1;

while (flag[1] && turn == 1) {

// busy wait

}

// critical section

flag[0] = 0;

// remainder section

}

void process1() {

flag[1] = 1;

turn = 0;

while (flag[0] && turn == 0) {

// busy wait

}

// critical section

flag[1] = 0;

// remainder section

}

It ensures that only one process can be in the critical section at a time.
It allows both processes to enter the critical section simultaneously.
It ensures no process can enter the critical section.
It always allows process0 to enter the critical section first.
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Consider the following code segment to achieve mutual exclusion. Which of the following conditions must be true for process0 to enter the critical section?

flag[0] = 1;

turn = 1;

while (flag[1] && turn == 1) {

// busy wait

}

// critical section

flag[1] == 0 or turn == 0
flag[1] == 1 and turn == 1
flag[1] == 0 and turn == 1
flag[1] == 1 or turn == 0
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
What is the purpose of the function in the context of mutual exclusion?

bool function(bool *lock) {

bool old = *lock;

*lock = true;

return old;

}

To atomically test the lock and set it to false if it was true.
To atomically test the lock and set it to true if it was false.
To atomically test the lock and reset it to its original state.
To set the lock without testing its current value.
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Consider the following use of test_and_set for implementing mutual exclusion. What condition allows a process to enter the critical section?

bool lock = false;

void enter_critical_section() {

while (test_and_set(&lock)) {

// busy wait

}

// critical section

}

void leave_critical_section() {

lock = false;

}

When test_and_set returns true.
When test_and_set returns false.
When the lock is set to true.
When the lock is set to false.
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Consider the following implementation of the test_and_set lock. Which statement about progress is correct?

bool lock = false;

void enter_critical_section() {

while (test_and_set(&lock)) {

// busy wait

}

// critical section

}

void leave_critical_section() {

lock = false;

}

Progress is guaranteed because at least one process will enter the critical section eventually.
Progress is not guaranteed because processes might be stuck in an infinite loop.
Progress is guaranteed because all waiting processes will enter the critical section in a predefined order.
Progress is not guaranteed because only one specific process will always enter the critical section.
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
In a system using the test_and_set lock, what would be a potential issue if the lock is not set to false after the critical section?
Mutual exclusion would be violated.
Progress would be guaranteed.
Bounded waiting would be guaranteed.
Processes might be permanently blocked, leading to a deadlock.
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Consider a scenario where two threads, T1 and T2, access a shared resource protected by a mutex. Thread T1 holds the mutex and is preempted by the operating system. What happens to the mutex?
The mutex is automatically released by the operating system.
The mutex is put into a waiting state until T1 resumes execution.
The mutex is still held by T1 until T1 explicitly releases it.
Another thread can acquire the mutex and continue execution.
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
In a system with 4 processes and 3 types of resources, what is the maximum number of edges that can exist in the Resource Allocation Graph (RAG) before it potentially indicates a deadlock?
6
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.00
Consider a system with 3 resource types (A, B, C) and 5 processes (P1, P2, P3, P4, P5). The current allocation and maximum demand matrices are provided below:

The total resources are (A,B,C) = (10,10,10). The total number of safe sequence possible are _____________

8
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.00
Suppose we have a counting semaphore S initialized with an initial value of 3. We perform the following operations on the semaphore:

Perform P(S) (wait operation) 5 times.

Perform V(S) (signal operation) 7 times.

Perform P(S) 3 more times.

Finally, perform V(S) 5 times.

The final value of S after these operations, considering the constraints of semaphore operations is _________

7
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.00