-
What is a critical section? Can you identify a critical section in the Pintos test
threads/alarm-wait.c
? -
Could you explain in details how this critical section could lead to a race condition bug and how that bug would affect the value of the variable
output_pos
? -
What is a mutex (a.k.a lock)?
-
What is a semaphore? How is it different from lock / mutex?
-
In the test
threads/priority-sema.c
, there are 10 threads executed in parallel (11 if you count the main thread). Could you give three scenarios of execution in which the maximum value of the semaphore is either 1, 2 or 10? -
Here is a very naive implementation of a lock. Could you explain why disabling the interrupts while holding the lock seems to be a good idea at first?
struct lock { } void acquire (lock) { disable_interrupts(); } void release (lock) { enable_interrupts(); }
-
However, could you also also explain why it is actually not a good idea after all?
-
How are locks actually implemented in Pintos?
-
Semaphores operations P and V requires multiple CPU instructions, how does Pintos ensure those operations are atomic?
-
What is a deadlock? Can you give a simple example of a deadlock?