ISC2 Certified Secure Software Lifecycle Professional (CSSLP) Practice Question
During a peer review of a C++ service, you notice several threads insert and delete entries in a shared std::map that is declared in global scope. Intermittent crashes and corrupted data have been reported in production. Which change will most effectively eliminate the race condition while keeping the code logic intact?
Increase the capacity of the map to reduce hash collisions and improve performance.
Recompile the code with maximum optimization flags (e.g., -O3) to streamline memory access.
Configure the runtime to spawn more worker threads so contention is less likely.
Guard all map insert, erase, and lookup operations with a mutex or similar lock.
A race condition occurs when multiple threads access shared data concurrently and at least one thread performs a write. Protecting every critical section that touches the shared stdmap with a mutual-exclusion object (e.g., stdmutex or a read-write lock) guarantees that only one thread can modify the map at a time, preserving internal consistency. Enlarging the container, changing thread counts, or enabling aggressive compiler optimizations do not address unsynchronized access and therefore cannot reliably prevent the data corruption.
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 race condition?
Open an interactive chat with Bash
What is a mutex and how does it prevent race conditions?
Open an interactive chat with Bash
Why doesn't increasing map capacity or spawning more threads solve race conditions?
Open an interactive chat with Bash
What is a race condition in programming?
Open an interactive chat with Bash
What is a std::mutex and how does it work?
Open an interactive chat with Bash
What is critical section guarding and why is it important?
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 .