static void* _profile_stream_thread(void* arg) { FOUNDATION_UNUSED(arg); thread_yield(); while (!thread_try_wait(4)) { profile_log(STRING_CONST("Thread message")); profile_begin_block(STRING_CONST("Thread block")); { profile_update_block(); profile_begin_block(STRING_CONST("Thread subblock")); { profile_log(STRING_CONST("Sub message")); profile_trylock(STRING_CONST("Trylock")); profile_lock(STRING_CONST("Trylock")); profile_wait(STRING_CONST("Wait")); profile_signal(STRING_CONST("Signal")); thread_sleep(2); profile_unlock(STRING_CONST("Trylock")); profile_log(STRING_CONST("End sub")); } profile_end_block(); profile_begin_block(STRING_CONST("Thread second subblock")); { profile_update_block(); profile_begin_block(STRING_CONST("Thread subblock")); { } profile_end_block(); } profile_end_block(); profile_trylock(STRING_CONST("Trylock")); thread_sleep(1); profile_lock(STRING_CONST("Trylock")); thread_sleep(4); profile_unlock(STRING_CONST("Trylock")); } profile_end_block(); atomic_add64(&_profile_generated_blocks, 14); } return 0; }
static void* _profile_stream_thread( object_t thread, void* arg ) { FOUNDATION_UNUSED( arg ); thread_yield(); while( !thread_should_terminate( thread ) ) { profile_log( "Thread message" ); profile_begin_block( "Thread block" ); { profile_update_block(); profile_begin_block( "Thread subblock" ); { profile_log( "Sub message" ); profile_trylock( "Trylock" ); profile_lock( "Trylock" ); profile_wait( "Wait" ); profile_signal( "Signal" ); thread_sleep( 2 ); profile_unlock( "Trylock" ); profile_log( "End sub" ); } profile_end_block(); profile_trylock( "Trylock" ); thread_sleep( 1 ); profile_lock( "Trylock" ); thread_sleep( 4 ); profile_unlock( "Trylock" ); } profile_end_block(); thread_sleep( 4 ); atomic_add64( &_profile_generated_blocks, 12 ); } return 0; }
static void* add_thread(void* arg) { int loop = 0; int32_t icount = 0; FOUNDATION_UNUSED(arg); while (!thread_try_wait(0) && (loop < 65535)) { for (icount = 0; icount < 128; ++icount) { atomic_add32(&val_32, icount % 2 ? -icount : icount); atomic_exchange_and_add64(&val_64, icount % 2 ? -icount : icount); } for (icount = 0; icount < 128; ++icount) { atomic_exchange_and_add32(&val_32, icount % 2 ? icount : -icount); atomic_add64(&val_64, icount % 2 ? icount : -icount); } ++loop; thread_yield(); } return 0; }
void* add_thread( object_t thread, void* arg ) { int loop = 0; int32_t icount = 0; while( !thread_should_terminate( thread ) && ( loop < 65535 ) ) { for( icount = 0; icount < 128; ++icount ) { atomic_add32( &val_32, icount % 2 ? -icount : icount ); atomic_exchange_and_add64( &val_64, icount % 2 ? -icount : icount ); } for( icount = 0; icount < 128; ++icount ) { atomic_exchange_and_add32( &val_32, icount % 2 ? icount : -icount ); atomic_add64( &val_64, icount % 2 ? icount : -icount ); } ++loop; thread_yield(); } return 0; }
int64_t new_log_id() { return atomic_add64(&g_log_id, 1); }