cre_tsk

acre_tsk

Outline

Create task.

C format

 ER      cre_tsk (ID tskid, T_CTSK *pk_ctsk );
 ER_ID   acre_tsk ( T_CTSK *pk_ctsk );
Parameter(s)

I/O

Parameter

Description

I

 ID      tskid;
ID number of the task.

I

 T_CTSK  *pk_ctsk;
Pointer to the packet containing the task creation information.



[Task creation information packet : T_CTSK]

 typedef struct  t_ctsk {
     ATR     tskatr;         /*Task attribute*/
     VP_INT  exinf;          /*Extended information*/
     FP      task;           /*Task start address*/
     PRI     itskpri;        /*Task initial priority*/
     SIZE    stksz;          /*User stack size (in bytes)*/
     VP      stk;            /*Start address of user stack*/
 } T_CTSK;


Explanation

This service call can be called from tasks that belong to Trusted Domain.

The cre_tsk creates a task with task ID indicated by tskid according to the content of pk_ctsk. The acre_tsk creates a task

according to the content of pk_ctsk, and returns the created task ID.

The processing performed at task creation is shown in Table 19-2.

Table 19-2 Processing Performed at Task Creation

No.

Content of processing

1

Clears the number of queued activation requests.

2

Resets the task state so that the task exception handling routine is not defined.



1 ) Task attribute (tskatr)
The following are specified for tskatr.


  tskatr := ( TA_HLNG  | [TA_ACT] | [TA_DOMdomid] )
The bit position of tskatr is shown as follows.

bit15bit8

bit7

bit6

bit5

bit4

bit3

bit2

bit1

bit0

0

Domain ID

TA_DOM(domid)

0

0

TA_ACT :1

TA_HLNG : 0



- TA_HLNG ( = 0x0000)
Only C-language is supported for task description language.


- TA_ACT ( = 0x0002)
When the TA_ACT attribute is specified, the created task makes a transition to the READY state. The processing performed at task activation is shown in Table 19-3. When the TA_ACT attribute is not specified, the created task makes a transition to the DORMANT state.


- TA_DOM(domid)
The created task belong to the domain indicated by domid. When 0 is specified for domid or TA_DOM(domid) is not specified, the created task belongs to the domain that the invoking task belong to.


Note For detail of TA_DOM macro, refer to "18.3.4 Macros for Domain".

2 ) Extended information (exinf)
When the task is activated by TA_ACT attribute, act_tsk or iact_tsk, exinf is passed to the task as argument. And exinf is passed to the task exception handling routine. The exinf can be widely used by the user, for example, to set information concerning the task.


3 ) Task start address (task)
Specify the task start address for task.


4 ) Task initial priority (itskpri)
Specify initial priority of the task for itskpri. Ranges of the value that can be specified are from 1 to TMAX_TPRI.


5 ) User stack size (stksz), Start address of user stack (stk)
The application acquires user stack area, and specifies the start address for stk and the size for stksz.
The user stack area must satisfy the following.



A ) The stk must be 16-bytes boundary. If not, error E_PAR is returned.

B ) The stksz must be multiple of 16. If not, error E_PAR is returned.

C ) The user stack area must not overwrap with either all user stacks and all memory objects. If not, an error is not detected and correct system operation cannot be guaranteed.

Note The mITRON4.0 specification defines the function that the kernel allocates user stack area when NULL is specified for stk. But RI600PX does not support this function.

Return value

Macro

Value

Description

-

Positive value

Normal completion of acre_tsk. (Created task ID)

E_OK

0

Normal completion of cre_tsk.

E_RSATR

-11

Reserved attribute

- Either bit0, bit2, bit3 or bit8-15 in tskatr is 1.

- VTMAX_DOMAIN < (Value of bit4-7 of tskatr)

E_PAR

-17

Parameter error.

- pk_ctsk == NULL

- task == NULL

- itskpri < 0

- TMAX_TPRI < itskpri

- stk is not 16-bytes boundary.

- stksz is not multiple of 16.

- stksz < (lower bound value described in Table 20-8

- VTMAX_AREASIZE < stksz

- stk + stksz > 0x100000000

E_ID

-18

Invalid ID number. (only for cre_tsk)

- tskid < 0

- tskid > VTMAX_TSK

E_CTX

-25

Context error.

- This service call was issued in the CPU locked state.

- This service call was issued from non-task.

- This service call was issued in the status "PSW.IPL > kernel interrupt mask level".

E_MACV

-26

Memory access violation.

- Stack pointer points out of user stack for invoking task.

- The operand-read access to the area indicated by pk_ctsk has not been permitted to the invoking task.

E_OACV

-27

Object access violation.

- The invoking task does not belong to trusted domain.

E_NOMEM

-33

Insufficient memory.

- stk == NULL

E_NOID

-34

No ID number available.(only for acre_tsk)

E_OBJ

-41

Object state error. (only for cre_tsk)

- The task specified by tskid exists.