#include #include #include #include struct global_t { int value; __monitor_t m; }; void ?{}(global_t * this) { this->value = 0; } static global_t global; void increment( /*mutex*/ global_t * this ) { monitor_guard_t g1 = { &this->m }; { monitor_guard_t g2 = { &this->m }; { monitor_guard_t g3 = { &this->m }; this->value += 1; } } } struct MyThread { thread 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; }