What is concurrency?
Concurrency occurs when multiple threads or processes make progress during overlapping periods, either simultaneously or through interleaved execution.
Study 5 Concurrency and Synchronization with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is concurrency?
Concurrency occurs when multiple threads or processes make progress during overlapping periods, either simultaneously or through interleaved execution.
What does mutual exclusion guarantee?
Mutual exclusion ensures that at most one thread at a time executes the protected section for a given resource.
How can a counting semaphore limit access to a resource pool?
A semaphore uses an atomic count to represent available resources; a counting semaphore initialized to 4 can limit access to four identical resources.
Which four conditions must all hold for classic resource deadlock?
The four conditions are mutual exclusion, hold and wait, no preemption, and circular wait. All must hold for the classic resource deadlock.
How do deadlock, starvation, and livelock differ?
Deadlock is permanent blocking caused by interdependent waits. Starvation is indefinite waiting while others repeatedly proceed; livelock is activity without useful progress.
How does synchronization coordinate a bounded producer-consumer buffer?
A mutex protects the queue; condition variables coordinate waiting. Producers wait while it is full, and consumers wait while it is empty.
How can concurrent increments cause a lost update?
Both threads may read the same old value before either writes, so one increment is lost. The result depends on execution timing.
What is a critical section?
A critical section is code that accesses shared data or a resource that must not be used concurrently.
What does progress mean for a critical-section solution?
Progress means that when no thread is in the section and some want to enter, choosing the next entrant is not postponed indefinitely.
What does bounded waiting prevent?
Bounded waiting means a thread requesting entry cannot be bypassed forever by other threads.
Why should a condition-variable waiter recheck its predicate in a loop?
A condition-variable wake-up does not prove the predicate is true. The thread must check the predicate again in a loop after waking.
How does a read-write lock coordinate readers and writers?
A read-write lock permits multiple readers at once, but excludes readers while a writer holds the lock.