library/src/threads/BP-LinuxThreads.cc
// Attempts to join all threads.  Needs to be called after dispatching any
// number of threads.  It prevents contention.
Attempts to join all threads.  Needs to be called after dispatching any
number of threads.  It prevents contention.
Attempts to join all threads . Needs to be called after dispatching any number of threads . It prevents contention .
BP_ERROR_T RejoinAllThreads(P_THREAD_LIST thread_list)
{
	if(!thread_list)
		return ERR_FAILURE;
	for
	(
		thread_list = thread_list->first;
		thread_list;
		thread_list = thread_list->next
	)
	{
		if(thread_list->threadId)
		{
			switch(pthread_join(thread_list->threadId, NULL))
			{
				case EINVAL:
					printf("\n pthread_join: EINVAL");
					break;
				case ESRCH:
					printf("\n pthread_join: ESRCH");
					break;
				case EDEADLK:
					printf("\n pthread_join: EDEADLK");
					break;
				default:
					break;
			}
		}
	}
	return ERR_SUCCESS;
}
BP_ERROR_T RejoinAllThreads ( P_THREAD_LIST thread_list ) { if ( ! thread_list ) return ERR_FAILURE ; for ( thread_list = thread_list -> first ; thread_list ; thread_list = thread_list -> next ) { if ( thread_list -> threadId ) { switch ( pthread_join ( thread_list -> threadId , NULL ) ) { case EINVAL : printf ( " \n " ) ; break ; case ESRCH : printf ( " \n " ) ; break ; case EDEADLK : printf ( " \n " ) ; break ; default : break ; } } } return ERR_SUCCESS ; }
Attempts to join all threads.
Attempts to join all threads .
// ensure we have a thread list to work with // printf("\n Attempting to join thread id: %u", thread_list->threadId); // printf("\n thread %u joined OK!", thread_list->threadId); // pthread_detach(thread_redispatch->threadId); // thread couldn't join