Task

group Task

Task management.

This part details OS tasks management.

Functions

static inline void *pi_thread_create(pi_task_entry_t func, void *arg, char *name, uint32_t stack_size, int32_t priority)

Create a thread.

This function creates an OS thread.

Parameters:
  • func – Thread entry function.

  • arg – Arguments to thread’s entry function.

  • name – Name of the thread.

  • stack_size – Stack size given to the thread.

  • priority – Thread priority.

Return values:
  • thread – Pointer to created thread.

  • NULL – If thread has not been created.

static inline void *pi_task_create(pi_task_entry_t func, void *arg, char *name, uint32_t stack_size, int32_t priority)

Deprecated:

This function is deprecated and will be removed in a future version of the SDK. Use ‘pi_thread_create’ instead.

static inline void *pmsis_task_create(pi_task_entry_t func, void *arg, char *name, int32_t priority)

Deprecated:

This function is deprecated and will be removed in a future version of the SDK. Use ‘pi_thread_create’ instead.

static inline void *pi_user_thread_create(pi_task_entry_t func, void *arg, char *name, uint32_t stack_size, int32_t priority)

Create a usermode thread.

This function creates a usermode thread.

Parameters:
  • func – Thread entry function.

  • arg – Arguments to thread’s entry function.

  • name – Name of the thread.

  • stack_size – Stack size given to the thread.

  • priority – Thread priority.

Return values:
  • thread – Pointer to created thread.

  • NULL – If thread has not been created.

static inline void *pi_user_task_create(pi_task_entry_t func, void *arg, char *name, uint32_t stack_size, int32_t priority)

Deprecated:

This function is deprecated and will be removed in a future version of the SDK. Use ‘pi_user_thread_create’ instead.

static inline void pi_thread_start(void *thread)

Starts a thread.

Calling this function starts a thread if it is starting automatically at creation.

Parameters:
  • thread – Pointer to the thread to start.

static inline void pi_thread_exit(void)

Exit a thread.

Calling this function terminates a thread.

Parameters:
  • thread – Pointer to the thread to exit.

static inline char *pi_thread_name_get(void *thread)

Get thread’s name.

This function returns the name of a thread.

Parameters:
  • thread – Pointer to the thread to get the name.

Returns:

Pointer to a char sequence, with the name of the thread.

static inline char *pi_thread_get_name(void *thread)

Deprecated:

This function is deprecated and will be removed in a future version of the SDK. Use ‘pi_thread_name_get’ instead.

static inline void pi_thread_suspend(void *thread)

Suspend a thread.

Calling this function suspends a thread. If given parameter thread is NULL, then the calling thread is suspended, and only an other thread can resume it.

Parameters:
  • thread – Pointer to the thread to suspend.

static inline void pmsis_task_suspend(void *thread)

Deprecated:

This function is deprecated and will be removed in a future version of the SDK. Use ‘pi_thread_suspend’ instead.

static inline void pi_thread_resume(void *thread)

Resume a thread.

Calling this function resumes a suspended thread.

Parameters:
  • thread – Pointer to the thread to suspend.

static inline void pi_thread_delete(void *thread)

Delete a thread.

Calling this function terminate a thread, and delete it. It ensures no remaining subthreads are running, and delegates the deletion of the thread to the event kernel. Therefore, a thread can not delete itself.

Parameters:
  • thread – Pointer to the thread to delete.

static inline void pi_thread_join(void *child_to_join)

Wait for a thread to be finished.

It waits for the given thread to be finished before continuing.

Parameters:
  • child – Pointer to the thread to wait. If NULL, waiting for all our childs.

static inline void pi_yield()

Call OS to switch context.

IMPLEM

This function can be called when a task should let another task run on CPU. In case of waiting for the end of some transfers, synchronisation,…