#include #include #include #include struct global_t { int value; monitor_desc m; }; void ?{}(global_t * this) { this->value = 0; } static global_t global; void increment( /*mutex*/ global_t * this ) { monitor_desc * mon = &this->m; monitor_guard_t g1 = { &mon }; { monitor_guard_t g2 = { &mon }; { monitor_guard_t g3 = { &mon }; this->value += 1; } } } struct MyThread { thread_desc t; }; DECL_THREAD(MyThread); void ?{}( MyThread * this ) {} void main( MyThread* this ) { for(int i = 0; i < 1000000; i++) { increment( &global ); } } int main(int argc, char* argv[]) { assert( global.m.entry_queue.tail != NULL ); processor p; { scoped(MyThread) f[4]; } sout | global.value | endl; }