Amazon Interview Question: Tell me what a critical secti... | Glassdoor

Interview Question

Senior Technical Program Manager Interview Seattle, WA

Tell me what a critical section is used for in C++.

Answer

Interview Answer

2 Answers

1

It is used to sequence threads within a process boundary.

Interview Candidate on Aug 13, 2013
3

A section of code which accesses shared memory such that only one thread should read/write from that location at a single time. Often mediated by semaphores or locks. Excessive use of critsecs negatively affects the performance of code running in a parallelized environment, since only one thread can access the critsec at a time. The more critsecs, and the longer each takes to execute, the less benefit you get from parallelization. If your entire program is enclosed in a critsec, it is effectively single threaded.

Still bears the scars of parallel computing on Aug 22, 2013

Add Answers or Comments

To comment on this, Sign In or Sign Up.