L10 Networks & OS Process Managment Flashcards
(28 cards)
What is the critical section problem in operating systems?
The critical section problem involves ensuring that when one process is executing in its critical section, no other process can execute in their critical section simultaneously.
Why does data inconsistency occur in concurrent systems?
Data inconsistency arises when multiple processes access and modify shared data concurrently without proper synchronisation mechanisms.
List the three requirements for a solution to the critical section problem.
1. Mutual Exclusion: Only one process in the critical section at a time
2. Progress: A decision about entry cannot be postponed indefinitely
3. Bounded Waiting: There is a bound on the number of times other processes can enter before one gets its turn
What is Peterson’s solution used for?
It’s a software algorithm to solve the critical section problem for two processes using shared flags and a turn variable.
What are the roles of flag[]
and turn
in Peterson’s solution?
flag[i]
indicates that process Pi wants to enter the critical section; turn
indicates whose turn it is. Mutual exclusion is achieved by checking both conditions.
What is a spinlock?
A spinlock is a lock that causes a thread to busy wait in a loop while trying to acquire it. It consumes CPU cycles while waiting.
What is a semaphore and how does it differ from a mutex?
A semaphore is a synchronisation tool that can manage access by multiple processes to a shared resource. Unlike a mutex, semaphores can allow more than one process in the critical section (counting semaphores).
Differentiate between binary and counting semaphores.
- Binary Semaphore: Can be 0 or 1, similar to mutex
- Counting Semaphore: Value can range over an unrestricted domain
What is a race condition?
A race condition occurs when multiple processes access and manipulate shared data concurrently, and the outcome depends on the order of access.
What issues do semaphores help resolve in process synchronisation?
Semaphores help avoid race conditions, ensure mutual exclusion, enforce execution order, and eliminate busy waiting with blocking mechanisms.
Describe the concept of a monitor in synchronisation.
A monitor is a high-level synchronisation construct that encapsulates shared variables and procedures, ensuring only one process executes in it at a time.
Name two classic synchronisation problems discussed in the lecture.
- Bounded Buffer (Producer-Consumer)
- Dining Philosophers
What concept is illustrated in Diagram1?
The Producer-Consumer problem using a bounded buffer, where the producer generates data and the consumer uses it.
In Diagram1, what does the buffer represent?
A fixed-size shared queue used to store items produced before they are consumed.
What does Diagram2 depict in the context of the producer?
The producer loop checks if the buffer is full, then adds an item and updates the in
index and counter.
What does the label ‘in = 3, counter = 3’ mean in Diagram3?
It shows that the buffer currently holds 3 items, and the next produced item will go at index 3.
What does the consumer do in Diagram4’s code block?
It waits if the buffer is empty, consumes an item at out
, then increments out
and decrements counter
.
What is the significance of ‘out = 1’ in Diagram5?
It indicates the consumer just removed the first item and will next read from index 1.
What race condition is illustrated in Diagram6?
The race condition on the counter
variable due to unsynchronised access by producer and consumer.
What does Diagram7 represent?
Peterson’s Algorithm for two processes ensuring mutual exclusion using flags and a turn variable.
What is the role of ‘acquire lock’ and ‘release lock’ in Diagram8 and Diagram9?
They represent entry and exit for the critical section using a lock mechanism, requiring busy wait.
What do the wait() and signal() operations do in Diagram10?
-
wait()
decrements the semaphore and may block the process -
signal()
increments it and may wake a waiting process
What ordering does Diagram11 enforce using semaphores?
It enforces S₂ to execute only after S₁ completes, using signal()
and wait()
.
How is busy waiting implemented in Diagram12?
The wait()
function uses a while(S <= 0);
loop, which continuously checks until the semaphore is available.