Explore tens of thousands of sets crafted by our community.
Locks, Mutexes, and Semaphores
15
Flashcards
0/15
Priority Inversion
Operation: A lower-priority thread holds a resource that a higher-priority thread needs, but the lower-priority thread is preempted by medium-priority threads. Use Case: Debugging unexpected application behavior due to suboptimal task scheduling.
Starvation
Operation: A thread is perpetually denied access to a shared resource or lock. Use Case: Diagnosing fairness issues in thread scheduling and resource allocation.
Condition Variable
Operation: Blocks the thread until a certain condition is met. Use Case: Allows threads to wait for certain conditions to be true before proceeding.
Lock-Free Algorithms
Operation: Algorithms designed so that multiple threads can operate on shared data without using locks, avoiding potential deadlocks. Use Case: Creating scalable and responsive multi-threaded programs.
Read-Write Lock (Shared-Exclusive Lock)
Operation: Differentiates access based on the operation (read or write), allowing multiple readers or one writer. Use Case: Optimizing performance when a resource is read more often than written to.
Barrier
Operation: Synchronizes a group of threads at a certain point in the program, ensuring all have reached the barrier before continuing. Use Case: Coordinating phased work, like in parallel algorithms where threads proceed in lockstep.
Livelock
Operation: A situation where threads remain active but are unable to make further progress. Use Case: Similar to deadlock in terms of thread starvation but with continuous state changes.
Atomic Operations
Operation: Operations that complete in a single step relative to other threads. Use Case: Implementing lock-free data structures and performing thread-safe operations without locking.
Spinlock
Operation: A type of lock that waits in a loop ('spins') while repeatedly checking if the lock is available. Use Case: Efficient in scenarios where the wait is expected to be very short.
Monitor
Operation: An abstract data type that controls access to shared resources with built-in synchronization primitives. Use Case: Simplifying the design of thread-safe classes by encapsulating access control.
Semaphore
Operation: A signaling mechanism that uses a counter to control access by multiple threads to a common resource. Use Case: Managing a fixed number of identical resources shared among threads.
Mutex (Mutual Exclusion)
Operation: Allows only one thread to access a resource at a time. Use Case: Protecting access to shared data in a multithreaded application.
Deadlock
Operation: Occurs when two or more threads are unable to proceed because each is waiting for the other to release a lock. Use Case: Understanding and troubleshooting thread starvation and unresponsive applications.
Transaction Memory
Operation: A concurrency control mechanism for simplifying the synchronization of threads that share memory. Use Case: Writing code that is automatically synchronized at the level of memory transactions.
Futex (Fast Userspace Mutex)
Operation: A lightweight, fast synchronization primitive that operates in user space until it detects contention, at which point it requests kernel help. Use Case: Efficiently handling infrequent contention in multithreaded applications.
© Hypatia.Tech. 2024 All rights reserved.