Thinking concurrently involves identifying parts of a problem that can be solved simultaneously to improve efficiency. Learners must be able to outline the
Topic Synopsis
Thinking concurrently involves identifying parts of a problem that can be solved simultaneously to improve efficiency. Learners must be able to outline the potential benefits and trade-offs associated with concurrent processing in specific scenarios.
Key Concepts & Core Principles
- Concurrency vs. parallelism: Concurrency is about dealing with multiple tasks at once (interleaving), while parallelism is about executing multiple tasks simultaneously on multiple cores.
- Race conditions: Occur when two or more threads access shared data simultaneously, and the outcome depends on the order of execution. They can be prevented using mutual exclusion.
- Mutual exclusion and semaphores: Mutual exclusion ensures that only one thread accesses a critical section at a time. Semaphores are a synchronisation primitive that can control access to shared resources.
- Deadlock: A situation where two or more threads are each waiting for resources held by the other, causing them to stall indefinitely. Deadlock requires four conditions: mutual exclusion, hold and wait, no preemption, and circular wait.
- Deterministic vs. non-deterministic behaviour: Concurrent systems are often non-deterministic because the interleaving of threads can vary, leading to different outcomes. Understanding this is key to debugging and testing.
Exam Tips & Revision Strategies
- Always relate the concept of concurrency to the specific problem context provided in the question
- Consider whether tasks are independent or if they require synchronization before proceeding
- Be prepared to discuss why some parts of a problem cannot be parallelized
Common Misconceptions & Mistakes to Avoid
- Confusing concurrency with multitasking or parallel hardware without understanding the algorithmic decomposition
- Failing to identify dependencies between tasks that prevent concurrent execution
- Overlooking the overhead costs associated with managing concurrent threads or processes
Examiner Marking Points
- Identification of tasks that can be executed in parallel
- Explanation of benefits of concurrent processing (e.g., reduced execution time)
- Explanation of trade-offs or challenges (e.g., overheads, synchronization, complexity)