Thread SlotS
Posted: Fri Aug 07, 2015 11:59 am
Is there a thread_join function in chibiOS 3.0 to do thread slots.
Code: Select all
static int thread_create( int client_fd )
{
int ret, i;
/*
* Find in-active or finished thread slot
*/
for( i = 0; i < MAX_NUM_THREADS; i++ )
{
if( threads[i].active == 0 )
break;
if( threads[i].data.thread_complete == 1 )
{
printf( " [ threading ] Cleaning up thread %d\n", i );
thread_join(threads[i].thread, NULL );
memset( &threads[i], 0, sizeof(pthread_info_t) );
break;
}
}
if( i == MAX_NUM_THREADS )
return( -1 );
/*
* Fill thread-info for thread
*/
memcpy( &threads[i].data, &base_info, sizeof(base_info) );
threads[i].active = 1;
threads[i].data.client_fd = client_fd;
if( ( ret = thread_create( &threads[i].thread, NULL, handle_ssl_connection, &threads[i].data ) ) != 0 )
{
return( ret );
}
return( 0 );
}