ct_self_data

The ct_self_data function returns a void pointer to the current thread's data.

Prototype:

void * ct_self_data( void );

Parameters:

None.

Return Value:

The same void pointer passed to ct_create_thread() or ct_create_sleeping_thread() when the current thread was created. If no thread is running, ct_self_data() returns NULL.

Discussion:

When cast to a pointer of the appropriate type, the pointer returned by ct_self_data() provides access to the current thread's data. This is the same pointer value received by the thread as a parameter when it receives control from the scheduler.

In principle the thread can pass its pointer down to whatever functions need it, without calling ct_self_data(). This function is a convenience for threads with deeply nested function calls, where passing a pointer all over the place would be tedious and annoying.

Restrictions:

It is sensible to call ct_self_data() only from a thread or user exit, i.e. while the scheduler is running. At any other time, ct_self_data() merely returns NULL.
Home