Operating Systems: Process Synchronisation & Concurrency Flashcards
What is the ability for multiple programs or tasks to appear to be executed simultaneously called?
Concurrency.
What does concurrency refer to in an OS context?
Any form of interaction among processes or threads.
How fundamental is concurrency to OS design?
Fundamental part.
List the key aspects that concurrency includes.
- Communication amongst processes/threads.
- Sharing of, and competition for, system resources.
- Cooperative processing of shared data.
- Synchronisation of process/thread activities.
- Solving deadlock and starvation problems.
How does concurrency arise at different levels of execution streams?
It arises in a similar way at multiple levels:
- Multi-programming.
- Multi-threading.
- Multi-processors.
- Multi-computers.
What is multi-programming in the context of concurrency?
The interaction between multiple processes running on one CPU, creating pseudo-parallelism (they appear to run simultaneously, but share one CPU).
What is multi-threading in the context of concurrency?
Multi-threading is the interaction between multiple threads running within one process.
What is multi-threading in the context of concurrency?
The interaction between multiple threads running within one process.
What is meant by multi-processors regarding concurrency?
Multi-processors involve multiple CPUs running multiple processes/threads, providing real parallelism (true simultaneous execution).
What is a multi-computer setup in concurrency terms?
Refers to multiple independent computers running distributed processes/threads that interact.
Do concurrency principles differ greatly across multi-programming, multi-threading, multi-processors, and multi-computers?
No. The principles of concurrency are basically the same in all these categories.
What are the three basic interaction types among processes or threads?
- Unaware of each other.
- Directly aware of each other.
- Indirectly aware of each other.
In concurrency, what does it mean when processes or threads are “unaware of each other”?
They must use shared resources independently, without interfering, and leave them intact for others.
In concurrency, what does it mean when processes or threads are “indirectly aware of each other”?
They work on common data and build
some result together via the data (“stigmergy” in biology), meaning they share data structures or files without direct communication but still affect each others work.
In concurrency, what does it mean when processes or threads are “directly aware of each other”?
They cooperate by communicating, for example, by exchanging messages.
Which two problems must concurrency mechanism address regarding processes and resources?
Deadlock (where processes block each other indefinitely), and starvation (where a process never gets needed resources).
Why is synchronisation important in concurrency?
Synchronisation ensures that processes/threads coordinate their actions properly (e.g., to avoid data corruption or inconsistent states).
What is a primary requirement when multiple processes/threads need to exchange information?
They require mechanism for communication (e.g., messages, shared memory, signals) to ensure data is passed safely and efficiently.
How does concurrency affect resource management?
Processes/threads may share and compete for system resources (CPU, memory , I/O devices), requiring scheduling, locks, or other coordination tools.
What does cooperative processing entail in concurrency?
It involves multiple processes/threads working together on the same data or tasks, often requiring synchronisation to maintain consistency.
What is the classic synchronisation problem involving two processes known as “producer and consumer”?
It is a classic scenario where one process produces data and the other process consumes it, highlighting the need for coordination to avoid race conditions and data inconsistencies.
What are the register-level steps for counter++ in the Producer?
- register1 = counter
- register1 = register1 + 1
- counter = register1
What are the register-level steps for counter– in the Consumer?
- register2 = counter
- register2 = register2 - 1
- counter = register2
Show a possible interleaving of instructions for Producer and Consumer when counter = 5.
- Producer loads counter (5) into register1
- Producer increments register1 → (now 6)
- Consumer loads counter (still 5 at this instant) into register2
- Consumer decrements register2 → (now 4)
- Producer writes back register1 (6) into counter
- Consumer writes back register2 (4) into counter
- Producer writes register1 (still 6) into counter again → final counter = 6
(This sequence illustrates how the final counter can be inconsistent with the expected result if the operations interleave.)