VSF Documented
vsf_thread.h File Reference
#include "kernel/vsf_kernel_cfg.h"
#include "../vsf_eda.h"
#include "./vsf_task.h"
#include "utilities/ooc_class.h"

Go to the source code of this file.

Macros

#define VSF_KERNEL_CFG_THREAD_STACK_PAGE_SIZE   1
 
#define VSF_KERNEL_CFG_THREAD_STACK_GUARDIAN_SIZE   0
 
#define VSF_KERNEL_CFG_THREAD_STACK_ALIGN_BIT   3
 
#define __VSF_THREAD_STACK_SAFE_SIZE(__stack)
 
#define __declare_vsf_thread(__name)
 
#define declare_vsf_thread(__name)
 Declare a thread type with embedded stack.
 
#define declare_vsf_thread_ex(__name)
 Declare a thread type using an external stack, same as declare_vsf_thread.
 
#define dcl_vsf_thread(__name)
 Alias of declare_vsf_thread.
 
#define dcl_vsf_thread_ex(__name)
 Alias of declare_vsf_thread_ex.
 
#define __vsf_thread_set_stack_canery(__thread, __task)
 
#define __vsf_thread_set_stack(__thread, __task, __stack_ptr, __stack_bytesize)
 
#define __vsf_thread_def_stack(__name, __bytesize)
 
#define __vsf_thread_def_stack_member(__name, __bytesize)
 
#define __vsf_thread_imp_stack(__name, __thread, __task)
 
#define __vsf_eda_call_thread_prepare_stack(__name, __thread)
 
#define __def_vsf_thread(__name, __stack_bytesize, ...)
 
#define __implement_vsf_thread(__name)
 
#define __vsf_eda_call_thread_prepare(__name, __thread_cb)
 
#define vsf_eda_call_thread_prepare(__name, __thread_cb)
 Prepare a thread control block before the current eda calls a thread.
 
#define vsf_eda_call_thread(__thread_cb)
 Call a prepared thread from the current eda and wait for its completion.
 
#define __def_vsf_thread_ex(__name, ...)
 
#define __implement_vsf_thread_ex(__name)
 
#define __vsf_eda_call_thread_prepare_ex__( __name, __thread_cb, __stack, __stack_bytesize)
 
#define vsf_eda_call_thread_prepare_ex( __name, __thread_cb, __stack, __stack_bytesize)
 Prepare a thread control block with an external stack before the current eda calls a thread.
 
#define vsf_eda_call_thread_ex(__thread_cb)
 Call a prepared thread (defined by def_vsf_thread_ex) from the current eda and wait for its completion.
 
#define def_vsf_thread(__name, __stack_bytesize, ...)
 Define a thread type with embedded stack.
 
#define define_vsf_thread(__name, __stack_bytesize, ...)
 Alias of def_vsf_thread.
 
#define def_vsf_thread_ex(__name, ...)
 Define a thread type using an external stack.
 
#define define_vsf_thread_ex(__name, ...)
 Alias of def_vsf_thread_ex.
 
#define end_def_vsf_thread(...)
 Mark the end of a thread definition, no-op, for readability only.
 
#define end_define_vsf_thread(...)
 Alias of end_def_vsf_thread.
 
#define implement_vsf_thread(__name)
 Implement the entry body of a thread type.
 
#define implement_vsf_thread_ex(__name)
 Implement the entry body of a thread type using an external stack.
 
#define imp_vsf_thread(__name)
 Alias of implement_vsf_thread.
 
#define imp_vsf_thread_ex(__name)
 Alias of implement_vsf_thread_ex.
 
#define __init_vsf_thread(__name, __task, __pri)
 
#define __init_vsf_thread_ex(__name, __task, __pri, __stack, __stack_bytesize)
 
#define init_vsf_thread(__name, __task, __pri)
 Initialize and start an instance of a thread type with embedded stack.
 
#define init_vsf_thread_ex(__name, __task, __pri, __stack, __stack_bytesize)
 Initialize and start an instance of a thread type with an external stack.
 
#define __vsf_thread(__name)
 
#define vsf_thread(__name)
 Get the thread control block type of a thread type.
 
#define vsf_thread_wfm   vsf_thread_wait_for_msg
 Short alias of vsf_thread_wait_for_msg.
 
#define vsf_thread_wfe   vsf_thread_wait_for_evt
 Short alias of vsf_thread_wait_for_evt.
 
#define vsf_thread_wfem   vsf_thread_wait_for_evt_msg
 Short alias of vsf_thread_wait_for_evt_msg.
 
#define __vsf_thread_call_sub(__name, __target, ...)
 
#define vsf_thread_call_sub(__name, __target, ...)
 Call an eda (event-driven task) sub-routine from a thread and wait for its completion.
 
#define vsf_thread_call_pt(__name, __target, ...)
 Call a pt (protothread) from a thread and wait for its completion.
 
#define vsf_thread_call_task(__name, __target, ...)
 Call a task from a thread and wait for its completion.
 
#define vsf_thread_delay_ms(__ms)
 Delay (sleep) the current thread for the given milliseconds.
 
#define vsf_thread_delay_us(__us)
 Delay (sleep) the current thread for the given microseconds.
 
#define vsf_thread_sem_post(__sem)
 Post a semaphore inside a thread, non-blocking alias of vsf_eda_sem_post.
 
#define vsf_thread_sem_pend(__sem, timeout)
 Pend on a semaphore inside a thread.
 
#define vsf_thread_trig_set(__trig, ...)
 Set a trigger inside a thread, non-blocking alias of vsf_eda_trig_set.
 
#define vsf_thread_trig_reset(__trig)
 Reset a trigger inside a thread, alias of vsf_eda_trig_reset.
 
#define vsf_thread_trig_pend(__trig, timeout)
 Pend on a trigger inside a thread.
 
#define vsf_thread_mutex_enter(__mtx, timeout)
 Enter (acquire) a mutex inside a thread.
 

Functions

 declare_class (vsf_thread_t) typedef void vsf_thread_sighandler_t(vsf_thread_t *thread
 POSIX-like thread signal handler, invoked when a signal is delivered to the thread.
 
 declare_class (vsf_thread_cb_t) typedef void vsf_thread_entry_t(vsf_thread_cb_t *thread)
 Thread entry function, called on the thread's own stack.
 

Variables

int sig
 

Macro Definition Documentation

◆ VSF_KERNEL_CFG_THREAD_STACK_PAGE_SIZE

#define VSF_KERNEL_CFG_THREAD_STACK_PAGE_SIZE   1

◆ VSF_KERNEL_CFG_THREAD_STACK_GUARDIAN_SIZE

#define VSF_KERNEL_CFG_THREAD_STACK_GUARDIAN_SIZE   0

◆ VSF_KERNEL_CFG_THREAD_STACK_ALIGN_BIT

#define VSF_KERNEL_CFG_THREAD_STACK_ALIGN_BIT   3

◆ __VSF_THREAD_STACK_SAFE_SIZE

#define __VSF_THREAD_STACK_SAFE_SIZE ( __stack)
Value:
( ( ( ((__stack) + VSF_KERNEL_CFG_THREAD_STACK_PAGE_SIZE - 1) \
#define VSF_KERNEL_CFG_THREAD_STACK_PAGE_SIZE
Definition vsf_thread.h:49
#define VSF_KERNEL_CFG_THREAD_STACK_GUARDIAN_SIZE
Definition vsf_thread.h:52

◆ __declare_vsf_thread

#define __declare_vsf_thread ( __name)
Value:
typedef struct __name __name; \
typedef struct thread_cb_##__name##_t thread_cb_##__name##_t;
#define __name
Definition hci_transport_aic8800.c:555

◆ declare_vsf_thread

#define declare_vsf_thread ( __name)
Value:
#define __declare_vsf_thread(__name)
Definition vsf_thread.h:84

Declare a thread type with embedded stack.

Parameters
[in]__namename of the thread type to declare
Note
Declares the thread instance type __name and its thread control block type thread_cb_#__name##_t; use def_vsf_thread to define them.

◆ declare_vsf_thread_ex

#define declare_vsf_thread_ex ( __name)
Value:

Declare a thread type using an external stack, same as declare_vsf_thread.

Parameters
[in]__namename of the thread type to declare
Note
Use def_vsf_thread_ex to define the thread type.

◆ dcl_vsf_thread

#define dcl_vsf_thread ( __name)
Value:
#define declare_vsf_thread(__name)
Declare a thread type with embedded stack.
Definition vsf_thread.h:101

Alias of declare_vsf_thread.

Parameters
[in]__namename of the thread type to declare

◆ dcl_vsf_thread_ex

#define dcl_vsf_thread_ex ( __name)
Value:

Alias of declare_vsf_thread_ex.

Parameters
[in]__namename of the thread type to declare

◆ __vsf_thread_set_stack_canery

#define __vsf_thread_set_stack_canery ( __thread,
__task )
Value:
(__thread)->canary = 0xDEADBEEF;

◆ __vsf_thread_set_stack

#define __vsf_thread_set_stack ( __thread,
__task,
__stack_ptr,
__stack_bytesize )
Value:
(__thread)->use_as__vsf_thread_cb_t.stack = (__stack_ptr); \
(__thread)->use_as__vsf_thread_cb_t.stack_size = (__stack_bytesize);\
__vsf_thread_set_stack_canery(__thread, __task)

◆ __vsf_thread_def_stack

#define __vsf_thread_def_stack ( __name,
__bytesize )
Value:
typedef enum { \
vsf_thread##__name##_stack_bytesize = (__bytesize), \
};
#define vsf_thread(__name)
Get the thread control block type of a thread type.
Definition vsf_thread.h:670

◆ __vsf_thread_def_stack_member

#define __vsf_thread_def_stack_member ( __name,
__bytesize )

◆ __vsf_thread_imp_stack

#define __vsf_thread_imp_stack ( __name,
__thread,
__task )
Value:
__vsf_thread_set_stack((__thread), (__task), NULL, (vsf_thread##__name##_stack_bytesize))
#define NULL
Definition lvgl.h:26
#define __vsf_thread_set_stack(__thread, __task, __stack_ptr, __stack_bytesize)
Definition vsf_thread.h:144

◆ __vsf_eda_call_thread_prepare_stack

#define __vsf_eda_call_thread_prepare_stack ( __name,
__thread )
Value:
.stack = NULL, \
.stack_size = (vsf_thread##__name##_stack_bytesize),

◆ __def_vsf_thread

#define __def_vsf_thread ( __name,
__stack_bytesize,
... )
Value:
__vsf_thread_def_stack(__name, (__stack_bytesize)) \
struct thread_cb_##__name##_t { \
implement(vsf_thread_cb_t) \
__VA_ARGS__ \
__vsf_thread_def_stack_member(__name, (__stack_bytesize)) \
}; \
struct __name { \
implement(vsf_thread_t) \
implement_ex(thread_cb_##__name##_t, param) \
} VSF_CAL_ALIGN(8); \
extern void vsf_thread_##__name##_start(struct __name *task, \
vsf_prio_t priority); \
extern void vsf_thread_##__name##_entry( \
struct thread_cb_##__name##_t *vsf_pthis);
#define VSF_CAL_ALIGN(__N)
Definition __compiler.h:187
void _start(void)
Definition startup_CMSDK_ARMv8MBL.c:62
vsf_prio_t
Kernel priority enumeration.
Definition vsf_kernel_common.h:55
#define __vsf_thread_def_stack(__name, __bytesize)
Definition vsf_thread.h:156

◆ __implement_vsf_thread

#define __implement_vsf_thread ( __name)
Value:
void vsf_thread_##__name##_entry( \
struct thread_cb_##__name##_t *vsf_pthis); \
void vsf_thread_##__name##_start( struct __name *task, \
vsf_prio_t priority) \
{ \
VSF_KERNEL_ASSERT(NULL != task); \
thread_cb_##__name##_t *__vsf_pthis = &(task->param); \
__vsf_pthis->use_as__vsf_thread_cb_t.entry = (vsf_thread_entry_t *)\
&vsf_thread_##__name##_entry; \
__vsf_thread_imp_stack(__name, __vsf_pthis, task) \
vsf_thread_start( &(task->use_as__vsf_thread_t), \
&(__vsf_pthis->use_as__vsf_thread_cb_t), \
priority); \
} \
void vsf_thread_##__name##_entry( \
struct thread_cb_##__name##_t *vsf_pthis)

◆ __vsf_eda_call_thread_prepare

#define __vsf_eda_call_thread_prepare ( __name,
__thread_cb )
Value:
do { \
thread_cb_##__name##_t *__vsf_pthis = (__thread_cb); \
const vsf_thread_prepare_cfg_t cfg = { \
.entry = (vsf_thread_entry_t *) \
&vsf_thread_##__name##_entry, \
}; \
vk_eda_call_thread_prepare(&(__vsf_pthis->use_as__vsf_thread_cb_t),\
(vsf_thread_prepare_cfg_t *)&cfg);\
} while(0)
#define __vsf_eda_call_thread_prepare_stack(__name, __thread)
Definition vsf_thread.h:163

◆ vsf_eda_call_thread_prepare

#define vsf_eda_call_thread_prepare ( __name,
__thread_cb )
Value:
#define __vsf_eda_call_thread_prepare(__name, __thread_cb)
Definition vsf_thread.h:214

Prepare a thread control block before the current eda calls a thread.

Parameters
[in]__namename of the thread type defined by def_vsf_thread
[in]__thread_cba pointer to the thread control block instance, of type vsf_thread(__name)
Returns
none
Note
Only available when VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL is ENABLED.
Call vsf_eda_call_thread after the preparation to run the thread and wait for its completion.
Must be called in eda task context (e.g. from an eda, pt or task event handler); the caller waits for the called thread to complete.

◆ vsf_eda_call_thread

#define vsf_eda_call_thread ( __thread_cb)
Value:
vk_eda_call_thread(&((__thread_cb)->use_as__vsf_thread_cb_t))
vsf_err_t vk_eda_call_thread(vsf_thread_cb_t *thread_cb)
Call a prepared thread from the current eda and wait for its completion.
Definition vsf_thread.c:561

Call a prepared thread from the current eda and wait for its completion.

Parameters
[in]__thread_cba pointer to the thread control block prepared by vsf_eda_call_thread_prepare
Returns
vsf_err_t: VSF_ERR_NONE if the call is started successfully; VSF_ERR_NOT_ENOUGH_RESOURCES if no frame is available
Note
Only available when VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL is ENABLED.
Must be called in eda task context (e.g. from an eda, pt or task event handler); the caller waits for the called thread to complete.

◆ __def_vsf_thread_ex

#define __def_vsf_thread_ex ( __name,
... )
Value:
struct thread_cb_##__name##_t { \
implement(vsf_thread_cb_t) \
__VA_ARGS__ \
}; \
struct __name { \
implement(vsf_thread_t) \
implement_ex(thread_cb_##__name##_t, param) \
}; \
extern void vsf_thread_##__name##_start( struct __name *task, \
vsf_prio_t priority, \
void *stack, \
extern void vsf_thread_##__name##_entry( \
struct thread_cb_##__name##_t *vsf_pthis);
unsigned int uint_fast32_t
Definition stdint.h:27
uint32_t size
Definition vsf_memfs.h:50

◆ __implement_vsf_thread_ex

#define __implement_vsf_thread_ex ( __name)
Value:
void vsf_thread_##__name##_entry( \
struct thread_cb_##__name##_t *vsf_pthis); \
void vsf_thread_##__name##_start( struct __name *task, \
vsf_prio_t priority, \
void *stack, \
{ \
VSF_KERNEL_ASSERT(NULL != task && 0 != size && NULL != stack); \
thread_cb_##__name##_t *__vsf_pthis = &(task->param); \
__vsf_pthis->use_as__vsf_thread_cb_t.entry = (vsf_thread_entry_t *)\
&vsf_thread_##__name##_entry; \
__vsf_pthis->use_as__vsf_thread_cb_t.stack = stack; \
__vsf_pthis->use_as__vsf_thread_cb_t.stack_size = size; \
vsf_thread_start( &(task->use_as__vsf_thread_t), \
&(task->param.use_as__vsf_thread_cb_t), \
priority); \
} \
void vsf_thread_##__name##_entry( \
struct thread_cb_##__name##_t *vsf_pthis)

◆ __vsf_eda_call_thread_prepare_ex__

#define __vsf_eda_call_thread_prepare_ex__ ( __name,
__thread_cb,
__stack,
__stack_bytesize )
Value:
do { \
VSF_KERNEL_ASSERT((NULL != (__stack)) && (0 != (__size))) \
thread_cb_##__name##_t *__vsf_pthis = (__thread_cb); \
const vsf_thread_prepare_cfg_t cfg = { \
.entry = (vsf_thread_entry_t *) \
&vsf_thread_##__name##_entry, \
.stack = (__stack), \
.stack_size = (__stack_bytesize), \
}; \
vk_eda_call_thread_prepare(&(__vsf_pthis->use_as__vsf_thread_cb_t),\
(vsf_thread_prepare_cfg_t *)&cfg);\
} while(0)

◆ vsf_eda_call_thread_prepare_ex

#define vsf_eda_call_thread_prepare_ex ( __name,
__thread_cb,
__stack,
__stack_bytesize )
Value:
(__thread_cb), \
(__stack), \
(__stack_bytesize))
#define __vsf_eda_call_thread_prepare_ex__( __name, __thread_cb, __stack, __stack_bytesize)
Definition vsf_thread.h:311

Prepare a thread control block with an external stack before the current eda calls a thread.

Parameters
[in]__namename of the thread type defined by def_vsf_thread_ex
[in]__thread_cba pointer to the thread control block instance, of type vsf_thread(__name)
[in]__stacka pointer to the external stack
[in]__stack_bytesizesize of the external stack in bytes
Returns
none
Note
Only available when VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL is ENABLED.
Call vsf_eda_call_thread_ex after the preparation to run the thread and wait for its completion.
Must be called in eda task context (e.g. from an eda, pt or task event handler); the caller waits for the called thread to complete.

◆ vsf_eda_call_thread_ex

#define vsf_eda_call_thread_ex ( __thread_cb)
Value:
vk_eda_call_thread(&((__thread_cb)->use_as__vsf_thread_cb_t))

Call a prepared thread (defined by def_vsf_thread_ex) from the current eda and wait for its completion.

Parameters
[in]__thread_cba pointer to the thread control block prepared by vsf_eda_call_thread_prepare_ex
Returns
vsf_err_t: VSF_ERR_NONE if the call is started successfully; VSF_ERR_NOT_ENOUGH_RESOURCES if no frame is available
Note
Only available when VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL is ENABLED.
Must be called in eda task context (e.g. from an eda, pt or task event handler); the caller waits for the called thread to complete.

◆ def_vsf_thread

#define def_vsf_thread ( __name,
__stack_bytesize,
... )
Value:
__def_vsf_thread(__name, (__stack_bytesize), __VA_ARGS__)
#define __def_vsf_thread(__name, __stack_bytesize,...)
Definition vsf_thread.h:180

Define a thread type with embedded stack.

Parameters
[in]__namename of the thread type, declared by declare_vsf_thread
[in]__stack_bytesizesize of the embedded stack in bytes
[in]...additional member variables bound to the thread, accessible via vsf_this/vsf_pthis in the thread entry
Note
Generates the thread instance type __name, the thread control block type thread_cb_#__name##_t, and the start function vsf_thread_#__name##_start(struct __name *task, vsf_prio_t priority).

◆ define_vsf_thread

#define define_vsf_thread ( __name,
__stack_bytesize,
... )
Value:
def_vsf_thread(__name, (__stack_bytesize), __VA_ARGS__)
#define def_vsf_thread(__name, __stack_bytesize,...)
Define a thread type with embedded stack.
Definition vsf_thread.h:479

Alias of def_vsf_thread.

Parameters
[in]__namename of the thread type, declared by declare_vsf_thread
[in]__stack_bytesizesize of the embedded stack in bytes
[in]...additional member variables bound to the thread

◆ def_vsf_thread_ex

#define def_vsf_thread_ex ( __name,
... )
Value:
#define __def_vsf_thread_ex(__name,...)
Definition vsf_thread.h:273

Define a thread type using an external stack.

Parameters
[in]__namename of the thread type, declared by declare_vsf_thread_ex
[in]...additional member variables bound to the thread, accessible via vsf_this/vsf_pthis in the thread entry
Note
No stack is embedded; the generated start function takes the external stack: vsf_thread_#__name##_start(struct __name *task, vsf_prio_t priority, void *stack, uint_fast32_t size).

◆ define_vsf_thread_ex

#define define_vsf_thread_ex ( __name,
... )
Value:
def_vsf_thread_ex(__name, __VA_ARGS__)
#define def_vsf_thread_ex(__name,...)
Define a thread type using an external stack.
Definition vsf_thread.h:517

Alias of def_vsf_thread_ex.

Parameters
[in]__namename of the thread type, declared by declare_vsf_thread_ex
[in]...additional member variables bound to the thread

◆ end_def_vsf_thread

#define end_def_vsf_thread ( ...)

Mark the end of a thread definition, no-op, for readability only.

◆ end_define_vsf_thread

#define end_define_vsf_thread ( ...)

Alias of end_def_vsf_thread.

◆ implement_vsf_thread

#define implement_vsf_thread ( __name)
Value:
#define __implement_vsf_thread(__name)
Definition vsf_thread.h:196

Implement the entry body of a thread type.

Parameters
[in]__namename of the thread type defined by def_vsf_thread
Note
The thread entry body follows this macro in braces; use vsf_this/vsf_pthis to access the members bound in def_vsf_thread.

◆ implement_vsf_thread_ex

#define implement_vsf_thread_ex ( __name)
Value:
#define __implement_vsf_thread_ex(__name)
Definition vsf_thread.h:290

Implement the entry body of a thread type using an external stack.

Parameters
[in]__namename of the thread type defined by def_vsf_thread_ex
Note
The thread entry body follows this macro in braces; use vsf_this/vsf_pthis to access the members bound in def_vsf_thread_ex.

◆ imp_vsf_thread

#define imp_vsf_thread ( __name)
Value:
#define implement_vsf_thread(__name)
Implement the entry body of a thread type.
Definition vsf_thread.h:562

Alias of implement_vsf_thread.

Parameters
[in]__namename of the thread type defined by def_vsf_thread

◆ imp_vsf_thread_ex

#define imp_vsf_thread_ex ( __name)
Value:
#define implement_vsf_thread_ex(__name)
Implement the entry body of a thread type using an external stack.
Definition vsf_thread.h:577

Alias of implement_vsf_thread_ex.

Parameters
[in]__namename of the thread type defined by def_vsf_thread_ex

◆ __init_vsf_thread

#define __init_vsf_thread ( __name,
__task,
__pri )
Value:
vsf_thread_##__name##_start((__task), (__pri))

◆ __init_vsf_thread_ex

#define __init_vsf_thread_ex ( __name,
__task,
__pri,
__stack,
__stack_bytesize )
Value:
vsf_thread_##__name##_start((__task), (__pri), (__stack), (__stack_bytesize))

◆ init_vsf_thread

#define init_vsf_thread ( __name,
__task,
__pri )
Value:
__init_vsf_thread(__name, (__task), (__pri))
#define __init_vsf_thread(__name, __task, __pri)
Definition vsf_thread.h:598

Initialize and start an instance of a thread type with embedded stack.

Parameters
[in]__namename of the thread type defined by def_vsf_thread
[in]__taska pointer to the thread instance of type __name
[in]__pripriority of the thread: vsf_prio_0, vsf_prio_1, ... (in increasing priority order), or vsf_prio_inherit (inherit the current event queue's priority)
Returns
none
Note
Calls the generated vsf_thread_#__name#_start function.
Must be called in task (or initialization) context, NOT in interrupt context.

◆ init_vsf_thread_ex

#define init_vsf_thread_ex ( __name,
__task,
__pri,
__stack,
__stack_bytesize )
Value:
__init_vsf_thread_ex(__name, (__task), (__pri), (__stack), (__stack_bytesize))
#define __init_vsf_thread_ex(__name, __task, __pri, __stack, __stack_bytesize)
Definition vsf_thread.h:601

Initialize and start an instance of a thread type with an external stack.

Parameters
[in]__namename of the thread type defined by def_vsf_thread_ex
[in]__taska pointer to the thread instance of type __name
[in]__pripriority of the thread: vsf_prio_0, vsf_prio_1, ... (in increasing priority order), or vsf_prio_inherit (inherit the current event queue's priority)
[in]__stacka pointer to the external stack
[in]__stack_bytesizesize of the external stack in bytes
Returns
none
Note
Calls the generated vsf_thread_#__name#_start function.
Must be called in task (or initialization) context, NOT in interrupt context.

◆ __vsf_thread

#define __vsf_thread ( __name)
Value:
thread_cb_##__name##_t

◆ vsf_thread

#define vsf_thread ( __name)
Value:
#define __vsf_thread(__name)
Definition vsf_thread.h:655

Get the thread control block type of a thread type.

Parameters
[in]__namename of the thread type defined by def_vsf_thread
Note
Expands to thread_cb_#__name##_t. Only available when VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL is ENABLED.

◆ vsf_thread_wfm

#define vsf_thread_wfm   vsf_thread_wait_for_msg

Short alias of vsf_thread_wait_for_msg.

Note
Must be called in thread context; the current thread is blocked until the operation completes.

◆ vsf_thread_wfe

#define vsf_thread_wfe   vsf_thread_wait_for_evt

Short alias of vsf_thread_wait_for_evt.

Note
Must be called in thread context; the current thread is blocked until the operation completes.

◆ vsf_thread_wfem

#define vsf_thread_wfem   vsf_thread_wait_for_evt_msg

Short alias of vsf_thread_wait_for_evt_msg.

Note
Only available when VSF_KERNEL_CFG_SUPPORT_EVT_MESSAGE is ENABLED.
Must be called in thread context; the current thread is blocked until the operation completes.

◆ __vsf_thread_call_sub

#define __vsf_thread_call_sub ( __name,
__target,
... )
Value:
(uintptr_t)(__target), \
(0, ##__VA_ARGS__), \
0, \
0)
uint32_t uintptr_t
Definition stdint.h:38
vsf_err_t vk_thread_call_eda(uintptr_t eda_handler, uintptr_t param, size_t local_size, size_t local_buff_size, uintptr_t local_buff)
Call an eda (event-driven task) from the current thread and wait for its completion.
Definition vsf_thread.c:672

◆ vsf_thread_call_sub

#define vsf_thread_call_sub ( __name,
__target,
... )
Value:
__vsf_thread_call_sub(__name, (__target), (0, ##__VA_ARGS__))
#define __vsf_thread_call_sub(__name, __target,...)
Definition vsf_thread.h:711

Call an eda (event-driven task) sub-routine from a thread and wait for its completion.

Parameters
[in]__nameentry function of the target eda
[in]__targeta pointer to the target eda instance
[in]...optional size of the local variables of the target eda
Returns
vsf_err_t: always VSF_ERR_NONE (frame exhaustion triggers an assertion in debug builds)
Note
Only available when VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL is ENABLED.
Must be called in thread context; the current thread is blocked until the called task completes.

◆ vsf_thread_call_pt

#define vsf_thread_call_pt ( __name,
__target,
... )
Value:
(__target)->fsm_state = 0; \
vsf_thread_call_sub(vsf_pt_func(__name), (__target), (0, ##__VA_ARGS__))
#define vsf_pt_func(__name)
Definition vsf_pt.h:462

Call a pt (protothread) from a thread and wait for its completion.

Parameters
[in]__namename of the target protothread defined by def_vsf_pt()
[in]__targeta pointer to the target pt instance
[in]...optional size of the local variables of the target pt
Returns
vsf_err_t: always VSF_ERR_NONE (frame exhaustion triggers an assertion in debug builds)
Note
The fsm_state of the target pt is reset before the call.
Only available when VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL is ENABLED.
Must be called in thread context; the current thread is blocked until the called task completes.

◆ vsf_thread_call_task

#define vsf_thread_call_task ( __name,
__target,
... )
Value:
vk_thread_call_task(vsf_task_func(__name), __target, (0, ##__VA_ARGS__))
#define vsf_task_func(__name)
Expand to the name of the task entry function.
Definition vsf_task.h:48
fsm_rt_t vk_thread_call_task(vsf_task_entry_t task_handler, uintptr_t param, size_t local_size)
Call a task from the current thread and wait for its completion.
Definition vsf_thread.c:711

Call a task from a thread and wait for its completion.

Parameters
[in]__nameentry function of the target task
[in]__targeta pointer to the target task instance
[in]...optional size of the local variables of the target task
Returns
fsm_rt_t: the final state of the called task
Note
Only available when VSF_KERNEL_CFG_EDA_SUPPORT_TASK and VSF_KERNEL_CFG_EDA_SUBCALL_HAS_RETURN_VALUE are ENABLED.
Must be called in thread context; the current thread is blocked until the called task completes.

◆ vsf_thread_delay_ms

#define vsf_thread_delay_ms ( __ms)
Value:
vsf_systimer_tick_t vsf_systimer_ms_to_tick(uint_fast32_t time_ms)
Definition linux_generic.c:440
void vsf_thread_delay(vsf_systimer_tick_t tick)
Delay (sleep) the current thread for the given ticks.
Definition vsf_thread.c:770

Delay (sleep) the current thread for the given milliseconds.

Parameters
[in]__msdelay time in milliseconds
Returns
none
Note
Only available when VSF_KERNEL_CFG_EDA_SUPPORT_TIMER is ENABLED.
Must be called in thread context; the current thread is blocked until the operation completes.

◆ vsf_thread_delay_us

#define vsf_thread_delay_us ( __us)
Value:
vsf_systimer_tick_t vsf_systimer_us_to_tick(uint_fast32_t time_us)
Definition linux_generic.c:435

Delay (sleep) the current thread for the given microseconds.

Parameters
[in]__usdelay time in microseconds
Returns
none
Note
Only available when VSF_KERNEL_CFG_EDA_SUPPORT_TIMER is ENABLED.
Must be called in thread context; the current thread is blocked until the operation completes.

◆ vsf_thread_sem_post

#define vsf_thread_sem_post ( __sem)
Value:
#define vsf_eda_sem_post(__psem)
Post (increase) a semaphore, waking up one pending task if any.
Definition vsf_eda.h:132

Post a semaphore inside a thread, non-blocking alias of vsf_eda_sem_post.

Parameters
[in]__sema pointer to structure vsf_sem_t
Returns
vsf_err_t: VSF_ERR_NONE if successful; VSF_ERR_OVERRUN if the count has reached the maximum
Note
Must be called in task context, NOT in interrupt context (in interrupt context use the corresponding _isr API if available).

◆ vsf_thread_sem_pend

#define vsf_thread_sem_pend ( __sem,
timeout )
Value:
__le16 timeout
Definition ieee80211.h:94
vsf_sync_reason_t __vsf_thread_wait_for_sync(vsf_sync_t *sync, vsf_timeout_tick_t time_out)
Wait for a sync object (semaphore, trigger or mutex) inside a thread.
Definition vsf_thread.c:832

Pend on a semaphore inside a thread.

Parameters
[in]__sema pointer to structure vsf_sem_t
[in]timeouttimeout in ticks; negative to wait forever, 0 to try once, a positive value to wait up to the given ticks
Returns
vsf_sync_reason_t: VSF_SYNC_GET if the semaphore is obtained, VSF_SYNC_TIMEOUT if timed out, VSF_SYNC_CANCEL if cancelled
Note
The current thread is blocked while waiting.
Must be called in thread context; the current thread is blocked until the operation completes.

◆ vsf_thread_trig_set

#define vsf_thread_trig_set ( __trig,
... )
Value:
vsf_eda_trig_set(__trig, ##__VA_ARGS__)
#define vsf_eda_trig_set(__pevt,...)
Set (trigger) a trigger, waking up the pending tasks.
Definition vsf_eda.h:403

Set a trigger inside a thread, non-blocking alias of vsf_eda_trig_set.

Parameters
[in]__triga pointer to structure vsf_trig_t
[in]...optional bool, true to set the trigger as manual-reset
Returns
vsf_err_t: VSF_ERR_NONE if successful; VSF_ERR_OVERRUN if the trigger is already set
Note
Must be called in task context, NOT in interrupt context (in interrupt context use the corresponding _isr API if available).

◆ vsf_thread_trig_reset

#define vsf_thread_trig_reset ( __trig)
Value:
#define vsf_eda_trig_reset(__pevt)
Reset a trigger to the untriggered state.
Definition vsf_eda.h:418

Reset a trigger inside a thread, alias of vsf_eda_trig_reset.

Parameters
[in]__triga pointer to structure vsf_trig_t
Returns
none
Note
Must be called in task context, NOT in interrupt context (in interrupt context use the corresponding _isr API if available).

◆ vsf_thread_trig_pend

#define vsf_thread_trig_pend ( __trig,
timeout )
Value:

Pend on a trigger inside a thread.

Parameters
[in]__triga pointer to structure vsf_trig_t
[in]timeouttimeout in ticks; negative to wait forever, 0 to try once, a positive value to wait up to the given ticks
Returns
vsf_sync_reason_t: VSF_SYNC_GET if the trigger is set, VSF_SYNC_TIMEOUT if timed out, VSF_SYNC_CANCEL if cancelled
Note
The current thread is blocked while waiting.
Must be called in thread context; the current thread is blocked until the operation completes.

◆ vsf_thread_mutex_enter

#define vsf_thread_mutex_enter ( __mtx,
timeout )
Value:
__vsf_thread_wait_for_sync(&(__mtx)->use_as__vsf_sync_t, timeout)

Enter (acquire) a mutex inside a thread.

Parameters
[in]__mtxa pointer to structure vsf_mutex_t
[in]timeouttimeout in ticks; negative to wait forever, 0 to try once, a positive value to wait up to the given ticks
Returns
vsf_sync_reason_t: VSF_SYNC_GET if the mutex is acquired, VSF_SYNC_TIMEOUT if timed out, VSF_SYNC_CANCEL if cancelled
Note
The current thread is blocked while waiting. Use vsf_thread_mutex_leave to release the mutex.
Must be called in thread context; the current thread is blocked until the operation completes.

Function Documentation

◆ declare_class() [1/2]

declare_class ( vsf_thread_t )

POSIX-like thread signal handler, invoked when a signal is delivered to the thread.

Parameters
[in]threadthe thread that receives the signal
[in]sigthe signal number
Note
Requires VSF_KERNEL_CFG_THREAD_SIGNAL to be ENABLED.

◆ declare_class() [2/2]

declare_class ( vsf_thread_cb_t )

Thread entry function, called on the thread's own stack.

Parameters
[in]threadthe thread control block vsf_thread_cb_t (when VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL is ENABLED)

Variable Documentation

◆ sig

int sig
Generated from commit: vsfteam/vsf@a5104db