โ† All CPP Flashcard Decks

Concurrency & Multithreading Flashcards

6 cards from real CPP practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 6 Concurrency & Multithreading flashcards as text
  1. What is thread starvation?

    Answer: A thread that is perpetually denied CPU time because higher-priority threads always preempt it

    Thread starvation happens when a thread never gets scheduled because other threads or high-priority tasks continuously consume CPU time.

  2. What is an atomic operation in concurrent programming?

    Answer: An operation that completes entirely without interruption, appearing instantaneous to other threads

    Atomic operations are indivisible from other threads' perspectives, preventing partial updates that could cause race conditions.

  3. What is the producer-consumer pattern?

    Answer: A concurrency pattern where producers add work to a shared queue and consumers process items from it

    The producer-consumer pattern decouples work generation from processing using a thread-safe buffer, enabling independent scaling of each side.

  4. What is thread-local storage (TLS)?

    Answer: A mechanism providing each thread with its own private copy of a variable

    Thread-local storage gives each thread its own instance of a variable, eliminating the need for synchronization on that data.

  5. What is lock-free programming?

    Answer: Designing concurrent algorithms that use atomic CPU operations instead of mutexes to avoid blocking threads

    Lock-free algorithms use atomic operations (like CAS) to coordinate threads without ever blocking, avoiding deadlock and reducing contention.

  6. What is a condition variable used for in threading?

    Answer: Allowing threads to block and wait until a specific condition becomes true, then be notified to wake up

    Condition variables work with a mutex to efficiently block a thread until another thread signals that a condition it needs has changed.