Esempio n. 1
0
/*-------------------------------------------------------------------*/
DLL_EXPORT void hthread_exit_thread( void* rc, const char* location )
{
    TID tid;
    tid = hthread_self();
    hthread_list_abandoned_locks( tid, location );
    hthread_exit( rc );
}
Esempio n. 2
0
void * testThreadWithMeasurement (void * arg)
{
    thread_arg_t * my_arg;
    my_arg = (thread_arg_t *)arg;
    Huint tid;

    tid = hthread_self();

    // Atomically increment counter (protected by data_mutex)
    dbg_printf("LOAD w/ measure TID %d, incrementing counter (%d -> %d) \n",tid,my_arg->counter,my_arg->counter+1);
    hthread_mutex_lock(&my_arg->data_mutex);
    my_arg->counter = my_arg->counter + 1;
    hthread_mutex_unlock(&my_arg->data_mutex);

    // Grab and release block mutex (protected by block_mutex) - should be pre-locked by main thread
    dbg_printf("LOAD w/ measure TID %d, locking block mutex\n",tid);
    my_arg->measure_lock_start = gettime(  );
    hthread_mutex_lock(&my_arg->block_mutex);
    my_arg->measure_lock_stop = gettime(  );
    dbg_printf("LOAD w/ measure TID %d, unlocking block mutex\n",tid);
    hthread_mutex_unlock(&my_arg->block_mutex);

    hthread_exit( NULL );
	return NULL;
}
Esempio n. 3
0
void* _bootstrap_thread( hthread_start_t func, void *arg )
{
    void *ret;
    
#ifdef HTHREADS_SMP
    while(!_release_syscall_lock());
#endif

    // Get start time
    hthread_time_t start = hthread_time_get();

    // Invoke  the start function and grab the return value
    ret = func( arg );
    
    // Get stop time and write execution time in TCB structure
    hthread_time_t stop = hthread_time_get();
    Huint tid = hthread_self();
    threads[tid].execution_time = stop-start;
     
    // Decrement the counter. It is safer to do this 
    // after hthread_exit but since we don't return
    // from this call, we will do it here.
    thread_counter--;
    
    // Exit the thread using the return value
    hthread_exit( ret );

    // This statement should never be reached
    return NULL;
}
Esempio n. 4
0
void* simpleThread( void *arg )
{
    uint thread_ctr;
    uint i;
    Huint thread_id;
    hthread_time_t t;

    thread_ctr = (uint)arg;
	thread_id = hthread_self();

    for (i=0; i<THREAD_ITERATIONS; i++)
    {
        printf("In Thread:  (TID= %u) (CTR= %u)\n", thread_id, thread_ctr);

        // idle for one second
        t = hthread_time_get() + CLOCKS_PER_SEC;
        while(hthread_time_get() < t);

        hthread_yield();
    }

    printf( "Exiting Thread:  (TID= %u) (CTR= %u)\n", thread_id, thread_ctr);
    hthread_exit(NULL);

    printf( "??? CODE AFTER THREAD EXIT, should not get here.\n");
    return NULL;
}
Esempio n. 5
0
void * measureThread (void * arg)
{
    thread_arg_t * my_arg;
    my_arg = (thread_arg_t *)arg;
    Huint tid;

    tid = hthread_self();

    // Pre-lock blocking mutex
    dbg_printf("MEASURE THREAD : Timing lock of block mutex\n");
    my_arg->lock_start = gettime(  );
    hthread_mutex_lock(&my_arg->block_mutex);
    my_arg->lock_stop = gettime(  );

    // Wait for all threads to block (i.e. wait for counter to reach limit)
    dbg_printf("### Waiting for counter value to be reached ###\n");
    while (my_arg->counter < my_arg->num_load_threads)
    {
        dbg_printf("Measurement thread yielding...(counter = %d)\n",my_arg->counter);
        hthread_yield();
    }
    dbg_printf("### Counter value reached ###\n");

    // (**B**) Unlock blocking mutex
    dbg_printf("MEASURE THREAD : Timing unlock of block mutex\n");
    my_arg->unlock_start = gettime(  );
    hthread_mutex_unlock(&my_arg->block_mutex);
    my_arg->unlock_stop = gettime(  );

    hthread_exit( NULL );
	return NULL;
}
Esempio n. 6
0
void * testThread ( void * arg ) {
	int retVal;

	retVal = hthread_yield();
	
	hthread_exit( (void *) retVal );
	return NULL;
}
Esempio n. 7
0
void * testThread ( void * arg ) {
	int retVal;
	struct test_data * data = (struct test_data *) arg;
	
	hthread_create( &data->thread, NULL, data->function, NULL );
	retVal = hthread_join( data->thread, NULL );
	
	hthread_exit( (void *) retVal );
	return NULL;
}
void * testThread ( void * arg ) {
	int retVal;
	hthread_mutex_t * mutex = (hthread_mutex_t *) arg;
	
	hthread_mutex_init( mutex, NULL );
	retVal = hthread_mutex_destroy( mutex );
	
	hthread_exit( (void *) retVal );
	return NULL;
}
void * testThread ( void * arg ) {
	int retVal;
	hthread_mutexattr_t * attr = (hthread_mutexattr_t *) arg;
	
	//Initialize an attribute, and check the return value
	retVal = hthread_mutexattr_init( attr );
	
	hthread_exit( (void *) retVal );
	return NULL;
}
Esempio n. 10
0
void * testThread ( void * arg ) {
	int retVal;
	hthread_cond_t * cond = (hthread_cond_t *) arg;
	
	hthread_cond_init( cond, NULL );
    retVal = hthread_cond_getnum( cond );
	
	hthread_exit( (void *) retVal );
	return NULL;
}
Esempio n. 11
0
void * testThread ( void * arg ) {
	int retVal;
	hthread_mutex_t * mutex = (hthread_mutex_t *) arg;
	
	//Test that the initialized mutex is not locked
	hthread_mutex_init( mutex, NULL );
	retVal = _mutex_owner( mutex->num );
	
	hthread_exit( (void *) retVal );
	return NULL;
}
Esempio n. 12
0
void * testThread ( void * arg ) {
	int retVal;
	struct testdata * data = (struct testdata *) arg;
	
	hthread_create( &data->thread, data->attr, data->function, NULL );
    hthread_attr_setdetachstate( data->attr, HTHREAD_CREATE_DETACHED );
	retVal = hthread_join( data->thread, NULL );
	
	hthread_exit( (void *) retVal );
	return NULL;
}
Esempio n. 13
0
void * testThread ( void * arg ) {
	int retVal;
	struct test_data * data = (struct test_data *) arg;
	
	hthread_create( &data->thread, NULL, data->function, NULL );
	hthread_join( data->thread, NULL );
	
	//If the thread exited, and we can join on it, its a success
	retVal = SUCCESS;
	
	hthread_exit( (void *) retVal );
	return NULL;
}
Esempio n. 14
0
void * testThread ( void * arg ) {
	int retVal;
	struct test_data * data = (struct test_data *) arg;

	hthread_mutex_lock( data->mutex );
	hthread_create( &data->thread, NULL, data->function, (void *) data );
	retVal = hthread_cond_wait( data->cond, data->mutex );
	hthread_mutex_unlock( data->mutex );
	
	hthread_join( data->thread, NULL );
	
	hthread_exit( (void *) retVal );
	return NULL;
}
Esempio n. 15
0
void * testThread ( void * arg ) {
	int retVal;
	hthread_mutex_t * mutex = (hthread_mutex_t *) arg;
	
	//Try to lock a locked mutex
	hthread_mutex_trylock( mutex );

	//Test that another thread owns the mutex	
	if ( _mutex_owner( mutex->num ) != hthread_self() )
		retVal = SUCCESS;
	else 
		retVal = FAILURE;
	
	hthread_exit( (void *) retVal );
	return NULL;
}
Esempio n. 16
0
void * testThread ( void * arg ) {
	int retVal;
	struct test_data * data = (struct test_data *) arg;
	
	//Initialize a mutexattr, then a mutex with the attr
	hthread_mutexattr_init( data->attr );
	hthread_mutex_init( data->mutex, data->attr );
	
	//Change the attr 
	data->attr->num = 1;
	
	//Get the num of the mutex, it should not have changed
	retVal = hthread_mutex_getnum( data->mutex );
	
	hthread_exit( (void *) retVal );
	return NULL;
}
Esempio n. 17
0
void * testThread ( void * arg ) {
	int retVal;
	hthread_mutex_t * mutex = (hthread_mutex_t *) arg;
	
	//Test that after trylock returns, on an unlocked mutex, the calling thread owns the mutex
	hthread_mutex_trylock( mutex );
	
	if ( _mutex_owner( mutex->num ) == hthread_self() )
		retVal = SUCCESS;
	else 
		retVal = FAILURE;
	
	hthread_mutex_unlock( mutex );
	
	hthread_exit( (void *) retVal );
	return NULL;
}
Esempio n. 18
0
void * testThread ( void * arg ) {
	int retVal, i;
	struct testdata * data = (struct testdata *) arg;

	for( i=0; i<THREAD_NUM; i++ )	
		hthread_create( &data->thread[i], NULL, data->function, (void *) data );
	while( *(data->start_num) != THREAD_NUM ) hthread_yield();
	hthread_mutex_lock( data->mutex );
	hthread_cond_broadcast( data->cond );
	hthread_mutex_unlock( data->mutex );
	for( i=0; i<THREAD_NUM; i++ )	
		hthread_join( data->thread[i], NULL );
	
	retVal = *(data->waken_num);
	
	hthread_exit( (void *) retVal );
	return NULL;
}
Esempio n. 19
0
void * foo( void* arg ) {
	hthread_exit(NULL);
	return NULL;
}
Esempio n. 20
0
void * a_thread_function(void * arg) {
	hthread_exit( NULL );
	return NULL;
}