Docs

You are here:
OSTask interface

Typedefs

typedef void(* OSTaskImplementation) (void *param)
 Task implementation type.
 

Enumerations

enum  OSTaskPriority {
  HAL_OSTASK_PRIORITY_NORMAL = 0, HAL_OSTASK_PRIORITY_LOWEST, HAL_OSTASK_PRIORITY_LOW, HAL_OSTASK_PRIORITY_HIGH,
  HAL_OSTASK_PRIORITY_HIGHEST
}
 Possible task priorities. More...
 

Functions

OSTask OSTASK_Create (OSTaskImplementation task_impl, OSTaskPriority priority, size_t stack_size, void *arg)
 
OSTask OSTASK_CreateJoinable (OSTaskImplementation task_impl, OSTaskPriority priority, size_t stack_size, void *arg)
 
void OSTASK_Destroy (OSTask task)
 
bool OSTASK_IsValid (OSTask task)
 
void OSTASK_Suspend (OSTask task)
 
void OSTASK_Resume (OSTask task)
 
void OSTASK_Yield (void)
 
bool OSTASK_Join (OSTask task, OSTime timeout)
 
OSTaskPriority OSTASK_GetPriority (OSTask task)
 
void OSTASK_SetPriority (OSTask task, OSTaskPriority priority)
 
OSTask OSTASK_GetCurrentTask (void)
 

Detailed Description

An interface to a task mechanism provided by the OS. The implementation of the OSTask depends on the OS used.

Enumeration Type Documentation

Possible task priorities.

Enumerator
HAL_OSTASK_PRIORITY_NORMAL 

normal priority (default)

HAL_OSTASK_PRIORITY_LOWEST 

lowest priority

HAL_OSTASK_PRIORITY_LOW 

low priority

HAL_OSTASK_PRIORITY_HIGH 

priority higher than normal

HAL_OSTASK_PRIORITY_HIGHEST 

highest priority (possibly most real-time)

Function Documentation

OSTask OSTASK_Create ( OSTaskImplementation  task_impl,
OSTaskPriority  priority,
size_t  stack_size,
void *  arg 
)

Creates a new task. The implementation depends on the actual OS.

Returns
handle of a newly created task
Parameters
task_implpointer to the task implementation function
prioritytask priority
stack_sizestack size (in bytes)
argtask argument
OSTask OSTASK_CreateJoinable ( OSTaskImplementation  task_impl,
OSTaskPriority  priority,
size_t  stack_size,
void *  arg 
)

Creates a new joinable task. The implementation depends on the actual OS. A joinable task MUST be joined using OSTASK_Join, otherwise memory leakage may occur.

Returns
handle of a newly created task
Parameters
task_implpointer to the task implementation function
prioritytask priority
stack_sizestack size (in bytes)
argtask argument
void OSTASK_Destroy ( OSTask  task)

Destroys a task

Parameters
taskhandle of the task to destroy
OSTask OSTASK_GetCurrentTask ( void  )

Retrieves the currently running task

Returns
handle of the currently running task
OSTaskPriority OSTASK_GetPriority ( OSTask  task)

Gets the priority of a task.

Returns
task priority
Parameters
taskhandle of the task
bool OSTASK_IsValid ( OSTask  task)

Checks if a task handle represents a valid task. Can be used to test if OSTASK_Create produced a valid task. Beware, that checking task handle of a task, that has been destroyed (OSTASK_Destroy) or successfully joined (OSTASK_Join) yields undefined behavior. On some ports such task handle may still be reported as valid.

Parameters
taskhandle of the task to check
Returns
true if task is valid or false if not
bool OSTASK_Join ( OSTask  task,
OSTime  timeout 
)

Waits for the task specified as a parameter to terminate. The task must be joinable - that is created using OSTASK_CreateJoinable function.

Parameters
taskhandle of the task to join
timeoutmaximum time allowed to wait for the task to terminate
Returns
true if the task is joinable and was terminated in the specified time, false otherwise
void OSTASK_Resume ( OSTask  task)

Resumes the execution of a task

Parameters
taskhandle of the task to resume
void OSTASK_SetPriority ( OSTask  task,
OSTaskPriority  priority 
)

Sets the priority of a task

Parameters
taskhandle of the task
prioritynew task priority
void OSTASK_Suspend ( OSTask  task)

Suspends the execution of a task

Parameters
taskhandle of the task to suspend
void OSTASK_Yield ( void  )

Causes the calling task to relinquish the CPU

Go to Top