A mutex provides exclusive access, a semaphore controls access to a limited number of resources, and a read-write lock allows multiple readers or one writer. Use them based on contention and access patterns.
Pick the right primitive for the pattern:
Use a semaphore for connection pooling:
max 20 DB connections -> semaphore(20)