ISC2 Certified Secure Software Lifecycle Professional (CSSLP) Practice Question
Performance profiling shows a C++ microservice where thousands of threads mostly read a shared stdmap of customer balances, while updates are rare. A single stdmutex guards all accesses but throttles throughput. Which change best maintains correctness and reduces contention in this read-heavy scenario?
Remove the lock entirely and rely on CPU cache coherence to keep the map consistent across threads.
Replace the single mutex with a readers-writer (shared) lock so multiple threads can read concurrently but writers still lock exclusively.
Mark the shared std::map variable as volatile to ensure all threads observe the latest values without locking.
Guard accesses with a counting semaphore whose permit count equals the number of worker threads.
A readers-writer (shared) lock lets many threads acquire a shared (read) lock concurrently, yet still enforces an exclusive lock when a thread modifies the map. This removes the bottleneck caused by a single exclusive mutex in read-dominated workloads while preventing race conditions during writes. Declaring the map volatile does not make compound operations atomic or thread-safe. A counting semaphore limits concurrency but treats every access the same, so it cannot differentiate safe reads from exclusive writes. Relying only on CPU cache coherence provides no ordering or atomicity guarantees for complex container operations, leaving the map vulnerable to data races.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is a readers-writer (shared) lock, and how does it work?
Open an interactive chat with Bash
Why doesn't marking a variable as volatile ensure thread safety?
Open an interactive chat with Bash
What is a counting semaphore, and why is it not suitable for this scenario?
Open an interactive chat with Bash
What is a readers-writer lock and how does it help in multi-threading?
Open an interactive chat with Bash
Why is marking a variable as volatile insufficient for thread safety?
Open an interactive chat with Bash
How does CPU cache coherence differ from locking mechanisms in thread safety?
Open an interactive chat with Bash
ISC2 Certified Secure Software Lifecycle Professional (CSSLP)
Secure Software Implementation
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .