Error checking – Comtrol eCos User Manual

Page 475

Advertising
background image

Chapter 32. µITRON API

The following two functions are supported in this release, when enabled with the configuration option

CYG-

PKG_UITRON_TASKS_CREATE_DELETE

with some restrictions:

ER

cre_tsk

(

ID tskid,

T_CTSK *pk_ctsk )

ER

del_tsk

(

ID tskid )

These functions are restricted as follows:

Because of the static initialization facilities provided for system objects, a task is allocated stack space statically
in the configuration. So while tasks can be created and deleted, the same stack space is used for that task (task ID
number) each time. Thus the stack size (pk_ctsk->stksz) requested in

cre_tsk()

is checked for being less than

that which was statically allocated, and otherwise ignored. This ensures that the new task will have enough stack
to run. For this reason

del_tsk()

does not in any sense free the memory that was in use for the task’s stack.

The task attributes (pk_ctsk->tskatr) are ignored; current versions of eCos do not need to know whether a task is
written in assembler or C/C++ so long as the procedure call standard appropriate to the CPU is followed.

Extended information (pk_ctsk->exinf) is ignored.

Error checking

For all these calls, an invalid task id (tskid) (less than 1 or greater than the number of configured tasks) only returns
E_ID when bad params return errors (

CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS

is enabled, see above).

Similarly,

the

following

conditions

are

only

checked

for,

and

only

return

errors

if

CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS

is enabled:

pk_crtk in

cre_tsk()

is a valid pointer, otherwise return E_PAR

ter_tsk()

or

rel_wai()

on the calling task returns E_OBJ

the CPU is not locked already in

dis_dsp()

and

ena_dsp()

; returns E_CTX

priority level in

chg_pri()

and

rot_rdq()

is checked for validity, E_PAR

return value pointer in

get_tid()

and

ref_tsk()

is a valid pointer, or E_PAR

The following conditions are checked for, and return error codes if appropriate, regardless of the setting of

CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS

:

When create and delete functions

cre_tsk()

and

del_tsk()

are supported, all calls which use a valid task ID

number check that the task exists; if not, E_NOEXS is returned

When supported,

cre_tsk()

: the task must not already exist; otherwise E_OBJ

When supported,

cre_tsk()

: the requested stack size must not be larger than that statically configured for the

task; see the configuration options “Static initializers”, and “Default stack size”. Else E_NOMEM

When supported,

del_tsk()

: the underlying eCos thread must not be running - this would imply either a bug

or some program bypassing the µITRON compatibility layer and manipulating the thread directly. E_OBJ

sta_tsk()

: the task must be dormant, else E_OBJ

371

Advertising