5.11.0.0R3
Software Development Kit
 
Loading...
Searching...
No Matches
Threads

Functions

wiced_result_t wiced_rtos_check_stack (void)
 
wiced_result_t wiced_rtos_create_thread (wiced_thread_t *thread, uint8_t priority, const char *name, wiced_thread_function_t function, uint32_t stack_size, void *arg)
 
wiced_result_t wiced_rtos_create_thread_with_stack (wiced_thread_t *thread, uint8_t priority, const char *name, wiced_thread_function_t function, void *stack, uint32_t stack_size, void *arg)
 
wiced_result_t wiced_rtos_delay_microseconds (uint32_t microseconds)
 
wiced_result_t wiced_rtos_delay_milliseconds (uint32_t milliseconds)
 
wiced_result_t wiced_rtos_delete_thread (wiced_thread_t *thread)
 
wiced_result_t wiced_rtos_is_current_thread (wiced_thread_t *thread)
 
wiced_result_t wiced_rtos_thread_force_awake (wiced_thread_t *thread)
 
wiced_result_t wiced_rtos_thread_join (wiced_thread_t *thread)
 
wiced_result_t wiced_rtos_thread_yield (void)
 

Detailed Description

Thread management functions. The following functions create a thread with a priority as defined below, deletes a thread, cancel a thread , creates a thread with stack size and checks for the current thread etc.

             - WICED thread priority table
                    - +----------+-----------------+
                    - | Priority |      Thread     |
                    - |----------|-----------------|
                    - |     0    |      Wiced      |   Highest priority
                    - |     1    |     Network     |
                    - |     2    |                 |
                    - |     3    | Network worker  |
                    - |     4    |                 |
                    - |     5    | Default Library |
                    - |          | Default worker  |
                    - |     6    |                 |
                    - |     7    |   Application   |
                    - |     8    |                 |
                    - |     9    |      Idle       |   Lowest priority
                    - +----------+-----------------+
                    - WICED_NETWORK_WORKER_PRIORITY      (3)
                    - WICED_DEFAULT_WORKER_PRIORITY      (5)
                    - WICED_DEFAULT_LIBRARY_PRIORITY     (5)
                    - WICED_APPLICATION_PRIORITY         (7)

RTOS for example ThreadX is pre-emptive .i.e Highest priority task always runs first, and the lower priority task runs later, if lower priority task is holding a Mutex and if higher priority thread is accessing the resource held by lower priority Mutex, then priority of the lower thread is increased to be the same of highest priority ( priority inheritance) so that Mutex is released and acquired by Higher Priority Task

API's to be called from an ISR(Interrupt Service Routine) Currently there is no WICED API which is called from an ISR, there is a low level API wwd_thread_notify_irq( ) which is called from an ISR, this is called by SDIO OOB (out of band) IRQ handler function for SDIO based chips such as 43438 and for 4390x it is platform_m2mdma_isr, which is registered in function platform_gpio_irq_enable( ) or PLATFORM_MAP_ISR() for 4390x

Function Documentation

◆ wiced_rtos_check_stack()

wiced_result_t wiced_rtos_check_stack ( void )

Checks the stack of the current thread

Returns
WICED_SUCCESS : if the current thread stack is within limits
WICED_ERROR : if the current thread stack has extended beyond its limits

◆ wiced_rtos_create_thread()

wiced_result_t wiced_rtos_create_thread ( wiced_thread_t * thread,
uint8_t priority,
const char * name,
wiced_thread_function_t function,
uint32_t stack_size,
void * arg )

Creates and starts a new thread with given priority, name and stack size.

Parameters
[out]thread: Pointer to variable that will receive the thread handle
[in]priority: A priority number or WICED_APPLICATION_PRIORITY.
[in]name: A text name for the thread (can be null)
[in]function: The main thread function
[in]stack_size: Stack size for this thread
[in]arg: Argument which will be passed to thread function
Returns
WICED_SUCCESS : on success.
WICED_ERROR : if an error occurred

◆ wiced_rtos_create_thread_with_stack()

wiced_result_t wiced_rtos_create_thread_with_stack ( wiced_thread_t * thread,
uint8_t priority,
const char * name,
wiced_thread_function_t function,
void * stack,
uint32_t stack_size,
void * arg )

Creates and starts a new thread with user provided stack

Parameters
[out]thread: Pointer to variable that will receive the thread handle
[in]priority: A priority number or WICED_APPLICATION_PRIORITY.
[in]name: A text name for the thread (can be null)
[in]function: The main thread function
[in]stack: The stack for this thread
[in]stack_size: Stack size for this thread
[in]arg: Argument which will be passed to thread function
Returns
WICED_SUCCESS : on success.
WICED_ERROR : if an error occurred

◆ wiced_rtos_delay_microseconds()

wiced_result_t wiced_rtos_delay_microseconds ( uint32_t microseconds)

Delay for a given period of microseconds

Causes the current thread to block for AT LEAST the specified number of microseconds. If the processor is heavily loaded with higher priority tasks, the delay may be much longer than requested.

NOTE: All threads with equal or lower priority than the current thread will not be able to run while the delay is occurring.

Parameters
[in]microseconds: The time to delay in microseconds
Returns
WICED_SUCCESS : on success.
WICED_ERROR : if an error occurred

◆ wiced_rtos_delay_milliseconds()

wiced_result_t wiced_rtos_delay_milliseconds ( uint32_t milliseconds)

Sleep for a given period of milliseconds

Causes the current thread to sleep for AT LEAST the specified number of milliseconds. If the processor is heavily loaded with higher priority tasks, the delay may be much longer than requested.

Parameters
[in]milliseconds: The time to sleep in milliseconds
Returns
WICED_SUCCESS : on success.
WICED_ERROR : if an error occurred

◆ wiced_rtos_delete_thread()

wiced_result_t wiced_rtos_delete_thread ( wiced_thread_t * thread)

Deletes a terminated thread

Parameters
[in]thread: The handle of the thread to delete
Returns
WICED_SUCCESS : on success.
WICED_ERROR : if an error occurred

◆ wiced_rtos_is_current_thread()

wiced_result_t wiced_rtos_is_current_thread ( wiced_thread_t * thread)

Checks if a specified thread is the current running thread

Parameters
[in]thread: The handle of the other thread against which the current thread will be compared
Returns
WICED_SUCCESS : specified thread is the current thread
WICED_ERROR : specified thread is not currently running

◆ wiced_rtos_thread_force_awake()

wiced_result_t wiced_rtos_thread_force_awake ( wiced_thread_t * thread)

Forcibly wakes another thread

Causes the specified thread to wake from suspension. This will usually cause an error or timeout in that thread, since the task it was waiting on is not complete.

Parameters
[in]thread: The handle of the other thread which will be woken
Returns
WICED_SUCCESS : on success.
WICED_ERROR : if an error occurred

◆ wiced_rtos_thread_join()

wiced_result_t wiced_rtos_thread_join ( wiced_thread_t * thread)

Sleeps until another thread has terminated

Causes the current thread to sleep until the specified other thread has terminated. If the processor is heavily loaded with higher priority tasks, this thread may not wake until significantly after the thread termination.

Parameters
[in]thread: The handle of the other thread which will terminate
Returns
WICED_SUCCESS : on success.
WICED_ERROR : if an error occurred

◆ wiced_rtos_thread_yield()

wiced_result_t wiced_rtos_thread_yield ( void )

Yield to higher priority thread

Returns
WICED_SUCCESS : if the current running thread is suspended
WICED_ERROR : if the current running thread is not suspended.