IntrOS
Loading...
Searching...
No Matches
Task

tasks (creation, control, delays) More...

Macros

#define STK_SIZE(size)
 size of the task stack in stk_t units: the size in bytes (rounded up) with the guard area
#define OS_TSK_STACK(stk, ...)
 define task stack
#define static_TSK_STACK(stk, ...)
 static alias of OS_TSK_STACK()
#define OS_WRK(tsk, proc, size)
 define and initialize complete work area for task object
#define static_WRK(tsk, proc, size)
 static alias of OS_WRK()
#define OS_TSK(tsk, proc, ...)
 define and initialize complete work area for task object with default stack size
#define static_TSK(tsk, proc, ...)
 static alias of OS_TSK()
#define OS_WRK_DEF(tsk, size)
 define and initialize complete work area for task object
#define static_WRK_DEF(tsk, size)
 static alias of OS_WRK_DEF()
#define OS_TSK_DEF(tsk, ...)
 define and initialize complete work area for task object with default stack size
#define static_TSK_DEF(tsk, ...)
 static alias of OS_TSK_DEF()
#define OS_WRK_START(tsk, size)
 define, initialize and start complete work area for task object
#define static_WRK_START(tsk, size)
 static alias of OS_WRK_START()
#define OS_TSK_START(tsk, ...)
 define, initialize and start complete work area for task object with default stack size
#define static_TSK_START(tsk, ...)
 static alias of OS_TSK_START()
#define WRK_INIT(proc, size)
 create and initialize complete work area for task object
#define WRK_CREATE(proc, size)
 create and initialize complete work area for task object
#define WRK_NEW   WRK_CREATE
 alias of WRK_CREATE()
#define TSK_INIT(proc, ...)
 create and initialize complete work area for task object with default stack size
#define TSK_CREATE(proc, ...)
 create and initialize complete work area for task object with default stack size
#define TSK_NEW   TSK_CREATE
 alias of TSK_CREATE()
#define SELF   ( System.cur )
 alias of tsk_this()

Functions

tsk_t * tsk_this (void)
 return current task object
tsk_t * cur_task (void)
 alias of tsk_this()
void wrk_init (tsk_t *tsk, fun_t *proc, stk_t *stack, size_t size)
 initialize complete work area for task object
void tsk_init (tsk_t *tsk, fun_t *proc, stk_t *stack, size_t size)
 initialize complete work area for task object and start the task, if proc != NULL
void tsk_start (tsk_t *tsk)
 start previously defined/created/stopped task object
void tsk_startFrom (tsk_t *tsk, fun_t *proc)
 start previously defined/created/stopped task object
void tsk_startWith (tsk_t *tsk, fun_a *proc, void *arg)
 start previously defined/created/stopped task object
void tsk_stop (void)
 stop execution of current task
void tsk_exit (void)
 alias of tsk_stop()
void tsk_reset (tsk_t *tsk)
 stop execution of given task
void tsk_kill (tsk_t *tsk)
 alias of tsk_reset()
void tsk_yield (void)
 yield system control to the next task
void tsk_pass (void)
 alias of tsk_yield()
void tsk_flip (fun_t *proc)
 restart current task with the new proc (task function)
void tsk_sleepFor (cnt_t delay)
 delay execution of current task for given duration of time
void tsk_delay (cnt_t delay)
 alias of tsk_sleepFor()
void tsk_sleepNext (cnt_t delay)
 delay execution of current task for given duration of time
void tsk_sleepUntil (cnt_t time)
 delay execution of current task until given timepoint
void tsk_sleep (void)
 delay indefinitely execution of current task
int tsk_suspend (tsk_t *tsk)
 delay indefinitely execution of given task
int tsk_resume (tsk_t *tsk)
 resume execution of given suspended task
size_t tsk_stackSpace (void)
 chack water mark of the stack of the current task

Detailed Description

tasks (creation, control, delays)

Macro Definition Documentation

◆ STK_SIZE

#define STK_SIZE ( size)
Value:
ALIGNED_SIZE((size_t)( size ) + (OS_GUARD_SIZE), sizeof(stk_t))

size of the task stack in stk_t units: the size in bytes (rounded up) with the guard area

◆ OS_TSK_STACK

#define OS_TSK_STACK ( stk,
... )
Value:
stk_t stk[ STK_SIZE( _VA_STK(__VA_ARGS__) ) ] __STKALIGN
#define STK_SIZE(size)
size of the task stack in stk_t units: the size in bytes (rounded up) with the guard area
Definition ostask.h:47

define task stack

Parameters
stkname of the stack (passed to the init function)
...size: (optional) size of task stack (in bytes); default: OS_STACK_SIZE

◆ static_TSK_STACK

#define static_TSK_STACK ( stk,
... )
Value:
static stk_t stk[ STK_SIZE( _VA_STK(__VA_ARGS__) ) ] __STKALIGN

static alias of OS_TSK_STACK()

◆ OS_WRK

#define OS_WRK ( tsk,
proc,
size )
Value:
static stk_t tsk##__stk[STK_SIZE( size )] __STKALIGN; \
tsk_t tsk[] = { _TSK_INIT( proc, tsk##__stk, STK_OVER( size ) ) }

define and initialize complete work area for task object

Parameters
tskname of a pointer to task object
proctask proc (initial task function) doesn't have to be noreturn-type it will be executed into an infinite system-implemented loop
sizesize of task private stack (in bytes)

◆ static_WRK

#define static_WRK ( tsk,
proc,
size )
Value:
static stk_t tsk##__stk[STK_SIZE( size )] __STKALIGN; \
static tsk_t tsk[] = { _TSK_INIT( proc, tsk##__stk, STK_OVER( size ) ) }

static alias of OS_WRK()

◆ OS_TSK

#define OS_TSK ( tsk,
proc,
... )
Value:
OS_WRK( tsk, proc, _VA_STK(__VA_ARGS__) )
#define OS_WRK(tsk, proc, size)
define and initialize complete work area for task object
Definition ostask.h:220

define and initialize complete work area for task object with default stack size

Parameters
tskname of a pointer to task object
proctask proc (initial task function) doesn't have to be noreturn-type it will be executed into an infinite system-implemented loop
...size: (optional) size of task private stack (in bytes); default: OS_STACK_SIZE

◆ static_TSK

#define static_TSK ( tsk,
proc,
... )
Value:
static_WRK( tsk, proc, _VA_STK(__VA_ARGS__) )
#define static_WRK(tsk, proc, size)
static alias of OS_WRK()
Definition ostask.h:225

static alias of OS_TSK()

◆ OS_WRK_DEF

#define OS_WRK_DEF ( tsk,
size )
Value:
static void tsk##__fun( void ); \
OS_WRK( tsk, tsk##__fun, size ); \
void tsk##__fun( void )

define and initialize complete work area for task object

     task proc (function body) must be defined immediately below
Parameters
tskname of a pointer to task object
sizesize of task private stack (in bytes)

◆ static_WRK_DEF

#define static_WRK_DEF ( tsk,
size )
Value:
static void tsk##__fun( void ); \
static_WRK( tsk, tsk##__fun, size ); \
static void tsk##__fun( void )

static alias of OS_WRK_DEF()

◆ OS_TSK_DEF

#define OS_TSK_DEF ( tsk,
... )
Value:
OS_WRK_DEF( tsk, _VA_STK(__VA_ARGS__) )
#define OS_WRK_DEF(tsk, size)
define and initialize complete work area for task object
Definition ostask.h:254

define and initialize complete work area for task object with default stack size

     task proc (function body) must be defined immediately below
Parameters
tskname of a pointer to task object
...size: (optional) size of task private stack (in bytes); default: OS_STACK_SIZE

◆ static_TSK_DEF

#define static_TSK_DEF ( tsk,
... )
Value:
static_WRK_DEF( tsk, _VA_STK(__VA_ARGS__) )
#define static_WRK_DEF(tsk, size)
static alias of OS_WRK_DEF()
Definition ostask.h:260

static alias of OS_TSK_DEF()

◆ OS_WRK_START

#define OS_WRK_START ( tsk,
size )
Value:
static void tsk##__fun( void ); \
OS_WRK( tsk, tsk##__fun, size ); \
__CONSTRUCTOR static void tsk##__run( void ) { tsk_start(tsk); } \
static void tsk##__fun( void )
void tsk_start(tsk_t *tsk)
start previously defined/created/stopped task object

define, initialize and start complete work area for task object

     task proc (function body) must be defined immediately below
Parameters
tskname of a pointer to task object
sizesize of task private stack (in bytes)
Note
only available for compilers supporting the "constructor" function attribute or its equivalent

◆ static_WRK_START

#define static_WRK_START ( tsk,
size )
Value:
static void tsk##__fun( void ); \
static_WRK( tsk, tsk##__fun, size ); \
__CONSTRUCTOR static void tsk##__run( void ) { tsk_start(tsk); } \
static void tsk##__fun( void )

static alias of OS_WRK_START()

◆ OS_TSK_START

#define OS_TSK_START ( tsk,
... )
Value:
OS_WRK_START( tsk, _VA_STK(__VA_ARGS__) )
#define OS_WRK_START(tsk, size)
define, initialize and start complete work area for task object
Definition ostask.h:293

define, initialize and start complete work area for task object with default stack size

     task proc (function body) must be defined immediately below
Parameters
tskname of a pointer to task object
...size: (optional) size of task private stack (in bytes); default: OS_STACK_SIZE
Note
only available for compilers supporting the "constructor" function attribute or its equivalent

◆ static_TSK_START

#define static_TSK_START ( tsk,
... )
Value:
static_WRK_START( tsk, _VA_STK(__VA_ARGS__) )
#define static_WRK_START(tsk, size)
static alias of OS_WRK_START()
Definition ostask.h:302

static alias of OS_TSK_START()

◆ WRK_INIT

#define WRK_INIT ( proc,
size )
Value:
_TSK_INIT( proc, _TSK_STACK( size ), STK_OVER( size ) )

create and initialize complete work area for task object

Parameters
proctask proc (initial task function) doesn't have to be noreturn-type it will be executed into an infinite system-implemented loop
sizesize of task private stack (in bytes)
Returns
task object
Note
use only in 'C' code

◆ WRK_CREATE

#define WRK_CREATE ( proc,
size )
Value:
{ WRK_INIT ( proc, size ) }
#define WRK_INIT(proc, size)
create and initialize complete work area for task object
Definition ostask.h:344

create and initialize complete work area for task object

Parameters
proctask proc (initial task function) doesn't have to be noreturn-type it will be executed into an infinite system-implemented loop
sizesize of task private stack (in bytes)
Returns
task object as array (id)
Note
use only in 'C' code

◆ TSK_INIT

#define TSK_INIT ( proc,
... )
Value:
WRK_INIT( proc, _VA_STK(__VA_ARGS__) )

create and initialize complete work area for task object with default stack size

Parameters
proctask proc (initial task function) doesn't have to be noreturn-type it will be executed into an infinite system-implemented loop
...size: (optional) size of task private stack (in bytes); default: OS_STACK_SIZE
Returns
task object
Note
use only in 'C' code

◆ TSK_CREATE

#define TSK_CREATE ( proc,
... )
Value:
WRK_CREATE( proc, _VA_STK(__VA_ARGS__) )
#define WRK_CREATE(proc, size)
create and initialize complete work area for task object
Definition ostask.h:361

create and initialize complete work area for task object with default stack size

Parameters
proctask proc (initial task function) doesn't have to be noreturn-type it will be executed into an infinite system-implemented loop
...size: (optional) size of task private stack (in bytes); default: OS_STACK_SIZE
Returns
task object as array (id)
Note
use only in 'C' code

Function Documentation

◆ tsk_this()

tsk_t * tsk_this ( void )
inline

return current task object

Returns
current task object

◆ wrk_init()

void wrk_init ( tsk_t * tsk,
fun_t * proc,
stk_t * stack,
size_t size )

initialize complete work area for task object

     don't start the task
Parameters
tskpointer to task object
proctask proc (initial task function) doesn't have to be noreturn-type it will be executed into an infinite system-implemented loop
stackbase of task's private stack storage
sizesize of task private stack (in bytes)

◆ tsk_init()

void tsk_init ( tsk_t * tsk,
fun_t * proc,
stk_t * stack,
size_t size )

initialize complete work area for task object and start the task, if proc != NULL

Parameters
tskpointer to task object
proctask proc (initial task function) doesn't have to be noreturn-type it will be executed into an infinite system-implemented loop
stackbase of task's private stack storage
sizesize of task private stack (in bytes)

◆ tsk_start()

void tsk_start ( tsk_t * tsk)

start previously defined/created/stopped task object

Parameters
tskpointer to task object

◆ tsk_startFrom()

void tsk_startFrom ( tsk_t * tsk,
fun_t * proc )

start previously defined/created/stopped task object

Parameters
tskpointer to task object
proctask proc (initial task function) doesn't have to be noreturn-type it will be executed into an infinite system-implemented loop

◆ tsk_startWith()

void tsk_startWith ( tsk_t * tsk,
fun_a * proc,
void * arg )

start previously defined/created/stopped task object

Parameters
tskpointer to task object
proctask initial procedure (initial task function)
argtask initial procedure argument (for internal use)

◆ tsk_stop()

void tsk_stop ( void )

stop execution of current task

     all mutexes held by the task are released (waiting tasks get E_STOPPED)

◆ tsk_reset()

void tsk_reset ( tsk_t * tsk)

stop execution of given task

     all mutexes held by the task are released (waiting tasks get E_STOPPED)

     other objects held by the task (e.g. semaphores, read/write locks) are not released
Parameters
tskpointer to task object
Note
use only in thread mode
readers waiting behind a writer stopped while waiting for a read/write lock are not released until the lock is given

◆ tsk_flip()

void tsk_flip ( fun_t * proc)

restart current task with the new proc (task function)

     all mutexes held by the task are released (waiting tasks get E_STOPPED)
Parameters
procnew task proc (task function)

◆ tsk_sleepFor()

void tsk_sleepFor ( cnt_t delay)

delay execution of current task for given duration of time

Parameters
delayduration of time (maximum number of ticks to delay execution of current task)
  • IMMEDIATE: don't delay execution of current task (only give up the processor once)
  • INFINITE: delay indefinitely execution of current task

◆ tsk_sleepNext()

void tsk_sleepNext ( cnt_t delay)

delay execution of current task for given duration of time

     from the end of the previous countdown
Parameters
delayduration of time (maximum number of ticks to delay execution of current task)
  • IMMEDIATE: don't delay execution of current task (only give up the processor once)
  • INFINITE: delay indefinitely execution of current task

◆ tsk_sleepUntil()

void tsk_sleepUntil ( cnt_t time)

delay execution of current task until given timepoint

Parameters
timetimepoint value
  • past timepoint: only give up the processor once

◆ tsk_sleep()

void tsk_sleep ( void )
inline

delay indefinitely execution of current task

     execution of the task can be resumed

◆ tsk_suspend()

int tsk_suspend ( tsk_t * tsk)

delay indefinitely execution of given task

     execution of the task can be resumed
Parameters
tskpointer to task object
Return values
E_SUCCESStask was successfully suspended
E_FAILUREtask cannot be suspended
Note
use only in thread mode

◆ tsk_resume()

int tsk_resume ( tsk_t * tsk)

resume execution of given suspended task

     only suspended or indefinitely blocked tasks can be resumed
Parameters
tskpointer to suspended task object
Return values
E_SUCCESStask was successfully resumed
E_FAILUREtask cannot be resumed

◆ tsk_stackSpace()

size_t tsk_stackSpace ( void )
inline

chack water mark of the stack of the current task

Returns
high water mark of the stack of the current task
Return values
0DEBUG not defined or the current task is the main task (its stack size is unknown)