Software Development Kit
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
Thread Management


#define ltrx_preemption_block()   ltrx_preemption_block_do_not_call_directly(__FILE__, __LINE__)
 Block preemption. More...
#define ltrx_thread_sleep(timeMsec)   ltrx_thread_sleep_do_not_call_directly(__FILE__, __LINE__, timeMsec)
 Pause this thread. More...
#define ltrx_thread_yield()   ltrx_thread_yield_do_not_call_directly(__FILE__, __LINE__)
 Yield control to other threads. More...


void ltrx_preemption_unblock (void)
 Unblock preemption. More...
struct ltrx_thread * ltrx_thread_create (const char *name, void(*entry_function)(void *opaque), void *entry_opaque, uint32_t stack_size)
 Create a thread. More...
struct ltrx_thread * ltrx_thread_id (void)
 Get current thread ID. More...
void ltrx_thread_resume (struct ltrx_thread *thread)
 Resumes a thread. More...
void ltrx_thread_suspend (void)
 Suspend a thread. More...
void ltrx_thread_wake (struct ltrx_thread *thread)
 Wake a thread. More...

Detailed Description

Macro Definition Documentation

#define ltrx_preemption_block ( )    ltrx_preemption_block_do_not_call_directly(__FILE__, __LINE__)

Block preemption.

Prevents other threads from preempting this one. Interrupts are still allowed.

Paired with ltrx_preemption_unblock(), this is useful for protecting data or resource being shared with another thread to restrict when the other thread can access or change it.

Nesting of ltrx_preemption_block() and ltrx_preemption_unblock() is allowed.

#define ltrx_thread_sleep (   timeMsec)    ltrx_thread_sleep_do_not_call_directly(__FILE__, __LINE__, timeMsec)

Pause this thread.

Allows other threads to run if they are ready. Otherwize the processor will idle, saving power. After the sleep time expires, this thread will be allowed to run in turn.

[in]timeMsecSleep time in milliseconds.
#define ltrx_thread_yield ( )    ltrx_thread_yield_do_not_call_directly(__FILE__, __LINE__)

Yield control to other threads.

Allows other threads to run if they are ready. Unlike ltrx_thread_sleep(), this thread will be allowed to run again without delay if no other threads are ready.

Function Documentation

void ltrx_preemption_unblock ( void  )

Unblock preemption.

Ends blocking of preemption from previous call to ltrx_preemption_block().

struct ltrx_thread* ltrx_thread_create ( const char *  name,
void(*)(void *opaque)  entry_function,
void *  entry_opaque,
uint32_t  stack_size 

Create a thread.

This function creates a thread and starts it by calling entry_function with the entry_opaque parameter.

Pointer to the created struct.
Return values
NULLltrx_thread_create() failed.
[in]nameName of thread.
[in]entry_functionEntry function of thread.
[in]entry_opaqueData passed into thread function.
[in]stack_sizeDesired stack size in bytes.
struct ltrx_thread* ltrx_thread_id ( void  )

Get current thread ID.

Pointer to thread struct for the current thread.
void ltrx_thread_resume ( struct ltrx_thread *  thread)

Resumes a thread.

Resumes the designated thread that had previously suspended itself by calling ltrx_thread_suspend().

[in]threadThread to resume.
void ltrx_thread_suspend ( void  )

Suspend a thread.

Suspends the current thread. To resume, another thread must call ltrx_thread_resume() and provide this thread's ID.

Caution: A suspended thread will not resume via ltrx_thread_wake().

void ltrx_thread_wake ( struct ltrx_thread *  thread)

Wake a thread.

Wakes up the designated thread.

Caution: this will wake a thread waiting for a mutex or trigger as well as a thread that has directly called ltrx_thread_sleep().

[in]threadThread to wake.