#include void add_num( long * total, long val ) { __atomic_fetch_add( total, (long)val, __ATOMIC_SEQ_CST ); } int main() { printf("start\n"); processor p[4]; long total = 0; cofor( i; 10 ) { __atomic_fetch_add( &total, i, __ATOMIC_SEQ_CST ); } { corun; // does nothing corun{}; // does nothing corun add_num( &total, 11 ); corun { add_num( &total, 12 ); } corun __atomic_fetch_add( &total, 13, __ATOMIC_SEQ_CST ); corun { __atomic_fetch_add( &total, 14, __ATOMIC_SEQ_CST ); } __atomic_fetch_add( &total, 15, __ATOMIC_SEQ_CST ); // run by main thd } printf("total: %ld\n", total); printf("done\n"); }