tk_ter_tsk

Terminate Task

See Also

[C Language Interface]

ER ercd = tk_ter_tsk ( ID tskid ) ;

[Parameters]

ID tskid Task ID

[Return Parameters]

ER	ercd	Error code

[Error Codes]

E_OK      Normal completion
E_ID      Invalid ID number (tskid is invalid or cannot be used)
E_NOEXS   Object does not exist (the task specified in tskid does not exist)
E_OBJ     Invalid object state (the target task is in DORMANT state or is the invoking task)

[Description]

Forcibly terminates the task specified in tskid.

This system call changes the state of the target task specified in tskid to DORMANT state.

Even if the target task was in a wait state (including SUSPEND state), the wait state is released and the task is terminated. If the target task was in some kind of queue (semaphore wait, etc.), executing tk_ter_tsk results in its removal from the queue.

This system call cannot specify the invoking task. If the invoking task is specified, error code E_OBJ is returned.

The relationships between target task states and the results of executing tk_ter_tsk are summarized in Table 4.1.

Table 4.1: Target Task State and Execution Result (tk_ter_tsk)

[Additional Notes]

When a task is terminated by tk_ter_tsk, the resources acquired by the task up to that time (memory blocks, semaphores, etc..) are not automatically released. The user is responsible for releasing such resources before the task is terminated.

As a rule, the task priority and other information included in the TCB are reset when the task returns to DORMANT state. If, for example, the task priority is changed by tk_chg_pri and later terminated by tk_ter_tsk, the task priority reverts to the startup priority (itskpri) specified when the task was started. It does not keep the task priority in effect at the time tk_ter_tsk was executed.

Forcible termination of another task is intended for use only by a debugger or a few other tasks closely related to the OS. As a rule, this system call is not to be used by ordinary applications or middleware for the following reason:

Forced termination occurs irrespective of the running state of the target task.

If, for example, a task is forcibly terminated while the task is calling a middleware function, the task would terminate right in the middle of the middleware execution. If such a situation is allowed, normal operation of the middleware cannot be guaranteed. This is an example of how task termination cannot be allowed when the task status (what it is being executed) is unknown. Ordinary applications therefore must not use the forcible termination function.

Comments

Click here to Post a Comment