High-level language support routine capability is provided so that even if a task or handler is written in high-level language, the kernel-related processing can be kept separate from the language environment-related processing. Whether or not a high-level language support routine is used is specified in TA_HLNG, one of the object attributes and handler attributes.
When TA_HLNG is not specified, a task or handler is started directly from the start address passed in a parameter to tk_cre_tsk or tk_def_???; whereas when TA_HLNG is specified, first the high-level language startup processing routine (high-level language support routine) is started, then from this routine an indirect jump is made to the task start address or handler address passed in a parameter to tk_cre_tsk or tk_def_???. Viewed from the kernel, the task start address or handler address is a parameter given to the high-level language support routine. Separating the kernel processing from the language environment processing in this way facilitates support for different language environments.
Use of high-level language support routines has the further advantage that when a task or handler is written as a C language function, a system call for task exit or return from a handler can be executed automatically, simply by performing a function return (explicit
return or "}").
In a system that uses an MMU, however, whereas it is relatively easy to realize a high-level language support routine in the case of an interrupt handler or the like that runs at the same protection level as the kernel, it is more difficult in the case of a task or task exception handler running at a different protection level from the kernel's. For this reason, when a high-level language support routine is used for a task, there is no guarantee that the task will exit by a return from the function. Returning a task function using
return or "}" leads to an undefined behavior. At the end of a task, Exit Task (tk_ext_tsk) or Exit and Delete Task (tk_exd_tsk) must always be issued.
In the case of a task exception handler, the high-level language support routine is supplied as source code and is to be embedded in the user program.
The internal working of a high-level language support routine is as illustrated in Figure 1.