how to track thread termination?

Hi ALL I am using threadx. Is there any way i can wait on a thread. I need to know when a thread has completed its execution. This is possible in windows by using:

WaitForSingleObject((HANDLE)event, timeout);

Is there anything equivalent to that in threadx or any other rtos's.

Threadx only has the following APIs defined for threads. Can we use these to do the same.

UINT tx_thread_create(TX_THREAD *thread_ptr, CHAR *name_ptr,VOID (*entry_function)(ULONG), ULONG entry_input, VOID *stack_start, ULONG stack_size, UINT priority, UINT preempt_threshold, ULONG time_slice, UINT auto_start);

UINT tx_thread_delete(TX_THREAD *thread_ptr); TX_THREAD *tx_thread_identify(VOID);

UINT tx_thread_info_get(TX_THREAD *thread_ptr, CHAR **name, UINT *state, ULONG *run_count, UINT *priority, UINT *preemption_threshold, ULONG *time_slice, TX_THREAD **next_thread, TX_THREAD **next_suspended_thread);

UINT tx_thread_preemption_change(TX_THREAD *thread_ptr, UINT new_threshold, UINT *old_threshold);

UINT tx_thread_priority_change(TX_THREAD *thread_ptr, UINT new_priority, UINT *old_priority);

VOID tx_thread_relinquish(VOID);

UINT tx_thread_resume(TX_THREAD *thread_ptr);

UINT tx_thread_sleep(ULONG timer_ticks);

UINT tx_thread_suspend(TX_THREAD *thread_ptr);

UINT tx_thread_terminate(TX_THREAD *thread_ptr);

UINT tx_thread_time_slice_change(TX_THREAD *thread_ptr, ULONG new_time_slice, ULONG *old_time_slice);

UINT tx_thread_wait_abort(TX_THREAD *thread_ptr);

Thanks a LOT

1011 10
Reply to
one.zero.one.one
Loading thread data ...

AFAIK for ThreadX the only way to get a thread's state is to poll the state (you could do this in a repetitive thread which then signals an event):

UINT tx_thread_info_get( TX_THREAD *thread_ptr, CHAR **name, UINT *state, // see header files for the enum ULONG *run_count, UINT *priority, UINT *preemption_threshold, ULONG *time_slice, TX_THREAD **next_thread, TX_THREAD **next_suspended_thread );

or to signal an event from the thread itself just before the thread finishes in a _normal_ way, and never using an tx_thread_terminate() or the like.

If you do have the sources, you could easily add a function to the OS like:

tx_set_terminate_event(*TX_THREAD, *TX_EVENT, ULONG bits);

This would set in the TX_THREAD structure a pointer to an event that has to be signalled whenever a thread is terminated. Only the OS knows for sure when that state change happens...

111 11's, Arie de Muynck
Reply to
Arie de Muynck

Er, have the waited upon thread send a signal to the waitee upon completion.

--
Nicholas O. Lindan, Cleveland, Ohio
Consulting Engineer:  Electronics; Informatics; Photonics.
 Click to see the full signature
Reply to
Nicholas O. Lindan

If you have to actually *wait* for it, it's probably the wrong plan to move that job to a separate thread in the first place. If you just want something done once the thread finishes, the thread should do that by itself.

--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Reply to
Hans-Bernhard Broeker

Thanks a LOT everyone.

Reply to
1011 10

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.