Thinking Concurrently Flashcards
What is concurrent processing?
Concurrent processing involves executing multiple tasks simultaneously, where tasks overlap in execution but don’t necessarily run at the exact same time.
Why is concurrent processing useful?
It increases program efficiency, allows multiple tasks to progress without waiting for others to complete, and maximizes CPU usage.
What is parallel processing?
Parallel processing is when multiple processors or cores execute different parts of a task simultaneously, often used in high-performance computing.
What is a key difference between concurrent and parallel processing?
Concurrent processing shares resources and overlaps tasks, while parallel processing performs multiple tasks at the same time with separate processors or cores.
Give an example of a situation where concurrent processing is useful.
Handling multiple user requests on a web server or downloading files while continuing to browse a website.
What are the challenges of concurrent processing?
Common challenges include deadlock, race conditions, and ensuring tasks share resources without conflicts.
What is deadlock?
Deadlock occurs when two or more tasks are blocked forever, waiting on each other to release resources.
What is a race condition?
A race condition happens when two or more tasks try to access shared resources simultaneously, leading to unpredictable results.
How can concurrency issues like deadlock be prevented?
Deadlock can be avoided through proper task scheduling, locking mechanisms, and ensuring tasks don’t wait indefinitely for resources.
What is a context switch?
A context switch is when the CPU changes from executing one task to another in concurrent processing, saving the state of the old task and loading the state of the new one.