void application_thread_cleanup( TX_THREAD *thread_ptr, UINT condition ) { /* Determine if the thread was exited. */ if ( thread_ptr && condition == TX_THREAD_EXIT ) { malloc_transfer_to_curr_thread(thread_ptr->tx_thread_stack_start); malloc_transfer_to_curr_thread(thread_ptr); tx_thread_terminate( thread_ptr ); malloc_leak_check(thread_ptr, LEAK_CHECK_THREAD); tx_thread_delete( thread_ptr ); free( thread_ptr->tx_thread_stack_start ); free( thread_ptr ); } }
/** * Deletes a terminated thread * * ThreadX requires that another thread deletes any terminated threads * * @param thread : handle of the terminated thread to delete * * @returns WWD_SUCCESS on success, WICED_ERROR otherwise */ wwd_result_t host_rtos_delete_terminated_thread( host_thread_type_t* thread ) { UINT status; status = tx_thread_delete( thread ); return ( status == TX_SUCCESS )? WWD_SUCCESS : WWD_THREAD_DELETE_FAIL; }