Go to the documentation of this file.
245 #if TN_PROFILER || DOXYGEN_ACTIVE
272 #if TN_PROFILER_WAIT_TIME || DOXYGEN_ACTIVE
306 #if TN_PROFILER_WAIT_TIME || DOXYGEN_ACTIVE
361 #if TN_MUTEX_DEADLOCK_DETECT
433 #if TN_PROFILER || DOXYGEN_ACTIVE
870 #if TN_PROFILER || DOXYGEN_ACTIVE
906 #endif // _TN_TASKS_H
enum TN_RCode tn_task_sleep(TN_TickCnt timeout)
Put current task to sleep for at most timeout ticks.
enum TN_WaitReason last_wait_reason
Available if only #TN_PROFILER_WAIT_TIME option is non-zero.
@ TN_WAIT_REASON_DQUE_WRECEIVE
Task wants to receive some data to the data queue, and there's no data in the queue.
@ TN_WAIT_REASON_MUTEX_I
Task wants to lock a mutex with priority inheritance.
enum TN_TaskState task_state
task state
TN_TaskBody * task_func_addr
pointer to task's body function given to tn_task_create()
@ TN_WAIT_REASON_DQUE_WSEND
Task wants to put some data to the data queue, and there's no space in the queue.
enum TN_RCode tn_task_suspend(struct TN_Task *task)
If the task is RUNNABLE, it is moved to the SUSPEND state.
struct TN_ListItem mutex_queue
list of all mutexes that are locked by task
enum TN_RCode task_wait_rc
waiting result code (reason why waiting finished)
unsigned long max_consecutive_wait_time[TN_WAIT_REASONS_CNT]
Available if only #TN_PROFILER_WAIT_TIME option is non-zero.
enum TN_RCode tn_task_resume(struct TN_Task *task)
Release task from SUSPEND state.
int tslice_count
time slice counter
enum TN_RCode tn_task_delete(struct TN_Task *task)
This function deletes the task specified by the task.
@ TN_TASK_STATE_SUSPEND
Task is suspended (by some other task)
struct TN_DQueueTaskWait dqueue
fields specific to tn_dqueue.h
enum TN_RCode tn_task_iactivate(struct TN_Task *task)
The same as tn_task_activate() but for using in the ISR.
unsigned priority_already_updated
Internal flag used to optimize mutex priority algorithms.
unsigned long long got_running_cnt
How many times task got running.
TN_UWord * stack_low_addr
– lowest address of stack.
struct TN_FMemTaskWait fmem
fields specific to tn_fmem.h
void() TN_TaskBody(void *param)
Prototype for task body function.
unsigned int TN_UWord
Unsigned integer type whose size is equal to the size of CPU register.
@ TN_TASK_EXIT_OPT_DELETE
whether task should be deleted right after it is exited.
TN_UWord * stack_high_addr
– Highest address of stack.
enum TN_RCode tn_task_change_priority(struct TN_Task *task, int new_priority)
Set new priority for task.
enum TN_RCode tn_task_create_wname(struct TN_Task *task, TN_TaskBody *task_func, int priority, TN_UWord *task_stack_low_addr, int task_stack_size, void *param, enum TN_TaskCreateOpt opts, const char *name)
The same as tn_task_create() but with additional argument name, which could be very useful for debug.
unsigned long max_consecutive_run_time
Maximum consecutive time task was running.
struct TN_ListItem * pwait_queue
pointer to object's (semaphore, mutex, event, etc) wait list in which task is included for waiting
FMem-specific fields related to waiting task, to be included in struct TN_Task.
enum TN_RCode tn_task_irelease_wait(struct TN_Task *task)
The same as tn_task_release_wait() but for using in the ISR.
const char * name
Task name for debug purposes, user may want to set it by hand.
@ TN_TASK_STATE_WAITSUSP
Task was previously waiting, and after this it was suspended.
@ TN_TASK_STATE_WAIT
Task is waiting.
DQueue-specific fields related to waiting task, to be included in struct TN_Task.
@ TN_WAIT_REASON_SLEEP
Task has called tn_task_sleep()
struct TN_TaskTiming timing
Main timing structure managed by profiler.
TN_TaskExitOpt
Options for tn_task_exit()
enum TN_RCode tn_task_state_get(struct TN_Task *task, enum TN_TaskState *p_state)
Get current state of the task; note that returned state is a bitmask, that is, states could be combin...
TN_TickCnt last_tick_cnt
Tick count of when the task got running or non-running last time.
enum TN_RCode tn_task_profiler_timing_get(const struct TN_Task *task, struct TN_TaskTiming *tgt)
Read profiler timing data of the task.
struct TN_EGrpTaskWait eventgrp
fields specific to tn_eventgrp.h
struct TN_ListItem create_queue
queue is used to include task in creation list (currently, this list is used for statistics only)
void tn_task_exit(enum TN_TaskExitOpt opts)
This function terminates the currently running task.
union TN_Task::@2 subsys_wait
subsystem-specific fields that are used while task waits for something.
struct TN_ListItem task_queue
queue is used to include task in ready/wait lists
unsigned long long total_wait_time[TN_WAIT_REASONS_CNT]
Available if only #TN_PROFILER_WAIT_TIME option is non-zero.
@ TN_TASK_STATE_DORMANT
Task isn't yet activated or it was terminated by tn_task_terminate().
enum TN_RCode tn_task_terminate(struct TN_Task *task)
This function is similar to tn_task_exit() but it terminates any task other than currently running on...
TN_RCode
Result code returned by kernel services.
TN_TaskCreateOpt
Options for tn_task_create()
@ TN_TASK_STATE_NONE
This state should never be publicly available.
@ TN_WAIT_REASON_SEM
Task waits to acquire a semaphore.
@ TN_WAIT_REASON_MUTEX_C
Task wants to lock a mutex with priority ceiling.
Timing structure that is managed by profiler and can be read by #tn_task_profiler_timing_get() functi...
unsigned long long total_run_time
Total time when task was running.
enum TN_RCode tn_task_release_wait(struct TN_Task *task)
Release task from WAIT state, independently of the reason of waiting.
struct TN_Timer timer
timer object to implement task waiting for timeout
enum TN_RCode tn_task_iwakeup(struct TN_Task *task)
The same as tn_task_wakeup() but for using in the ISR.
unsigned long TN_TickCnt
Type for system tick count, it is used by the kernel to represent absolute tick count value as well a...
enum TN_RCode tn_task_activate(struct TN_Task *task)
Activate task that is in DORMANT state, that is, it was either just created by tn_task_create() witho...
int base_priority
base priority of the task (actual current priority may be higher than base priority because of mutex)
unsigned waited
Flag indicates that task waited for something This flag is set automatially in _tn_task_set_waiting()...
struct TN_ListItem deadlock_list
list of other tasks involved in deadlock.
TN_UWord * stack_cur_pt
pointer to task's current top of the stack; Note that this field must be a first field in the struct,...
@ TN_WAIT_REASON_NONE
Task isn't waiting for anything.
EventGrp-specific fields related to waiting task, to be included in struct TN_Task.
@ TN_TASK_CREATE_OPT_START
whether task should be activated right after it is created.
@ TN_WAIT_REASON_EVENT
Task waits for some event in the event group to be set.
TN_ObjId
Magic number for object validity verification.
enum TN_ObjId id_task
id for object validity verification.
TN_WaitReason
Task wait reason.
@ TN_TASK_STATE_RUNNABLE
Task is ready to run (it doesn't mean that it is running at the moment)
@ TN_WAIT_REASON_WFIXMEM
Task wants to get memory block from memory pool, and there's no free memory blocks.
Circular doubly linked list item, for internal kernel usage.
int priority
current task priority
Internal kernel structure for profiling data of task.
void * task_func_param
pointer to task's parameter given to tn_task_create()
struct _TN_TaskProfiler profiler
Profiler data, available if only #TN_PROFILER is non-zero.
@ _TN_TASK_CREATE_OPT_IDLE
for internal kernel usage only: this option must be provided when creating idle task
enum TN_WaitReason task_wait_reason
reason for waiting (relevant if only task_state is WAIT or WAIT+SUSPEND)
enum TN_RCode tn_task_wakeup(struct TN_Task *task)
Wake up task from sleep.
enum TN_RCode tn_task_create(struct TN_Task *task, TN_TaskBody *task_func, int priority, TN_UWord *task_stack_low_addr, int task_stack_size, void *param, enum TN_TaskCreateOpt opts)
Construct task and probably start it (depends on options, see below).
@ TN_WAIT_REASONS_CNT
Wait reasons count.