Parallel
critical.txt
Associated article: Apply Critical Sections Consistently
Tags: Design JVM Languages .NET Open Source Parallel C/C++
Published source code in the article by Herb Sutter in which he examines critical code sections for guaranteeing mutual exclusion on shared variables.
Effective Concurrency
by Herb Sutter
// One Producer thread
//
while( there are more tasks ) {
task = AllocateAndBuildNewTask();
mut.lock(); // enter critical section
queue.push( task ); // add new task
mut.unlock(); // exit critical section
}
mut.lock(); // enter critical section
queue.push( done ); // add ...


