30.12.2013 Views

T-Kernel Specification (1.B0.02)

T-Kernel Specification (1.B0.02)

T-Kernel Specification (1.B0.02)

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

12 CHAPTER 2. CONCEPTS UNDERLYING THE T-KERNEL SPECIFICATION<br />

handlers can be designed for direct starting, basically without OS intervention, or for starting via a<br />

high-level language support routine.<br />

2.4 Task Exception Handling<br />

The T-<strong>Kernel</strong> specification defines task exception handling functions for dealing with exceptions. Note<br />

that exceptions other than those in the CPU are treated as interrupts.<br />

A task exception handling function is one that invokes a system call requesting task exception handling,<br />

interrupts execution by the designated task, and runs a task exception handler. Execution of the task<br />

exception handler takes place in the same context as the interrupted task. Upon return from the task<br />

exception handler, the interrupted processing continues. One task exception handler per task can be<br />

registered with an application.<br />

2.5 System States<br />

2.5.1 System States While Nontask Portion Is Executing<br />

When programming tasks to run on T-<strong>Kernel</strong>, the changes in task states can be tracked by looking at<br />

a task state transition diagram. In the case of routines such as interrupt handlers or extended SVC<br />

handlers, however, the user must perform programming at a level closer to the kernel than tasks. In this<br />

case consideration must be made also of system states while a nontask portion is executing, otherwise<br />

programming cannot be done properly. An explanation of T-<strong>Kernel</strong> system states is therefore given<br />

here.<br />

System states are classified as in Figure 2.6. Of these, a “transient state” is equivalent to OS running<br />

state (system call execution). From the standpoint of the user, it is important that each of the system<br />

calls issued by the user be executed indivisibly, and that the internal states while a system call is<br />

executing cannot be seen by the user. For this reason the state while the OS running is considered a<br />

“transient state” and internally it is treated as a blackbox. In the following cases, however, a transient<br />

state is not executed indivisibly.<br />

• When memory is being allocated or freed in the case of a system call that gets or releases memory<br />

(while a T-<strong>Kernel</strong>/SM system memory management function is called).<br />

• In a virtual memory system, when nonresident memory is accessed in system call processing.<br />

When a task is in a transient state such as these, the behavior of a task termination (tk ter tsk) system<br />

call is not guaranteed. Moreover, task suspension (tk sus tsk) may cause a deadlock or other problem<br />

by stopping without clearing the transient state. Accordingly, as a rule tk ter tsk and tk sus tsk<br />

cannot be used in programs. These system calls should be used only in a subsystem such as a virtual<br />

memory system or debugger that is so close to being an OS that it can be thought of as part of the OS.<br />

A task-independent portion and quasi-task portion are states while a handler is executing. The part of<br />

a handler that runs in a task context is a quasi-task portion, and the part with a context independent<br />

of a task is a task-independent portion. An extended SVC handler, which processes extended system<br />

calls defined by the user, is a quasi-task portion, whereas an interrupt handler or time event handler<br />

triggered by an external interrupt is a task-independent portion. In a quasi-task portion, tasks have the<br />

same kinds of state transitions as ordinary tasks and system calls can be issued even in WAIT state.<br />

A transient state, task-independent portion, and quasi-task portion are together called a nontask portion.<br />

When ordinary task programs are running, outside of these, this is “task portion running” state.<br />

Copyright c○ 2002, 2003 by T-Engine Forum<br />

T-<strong>Kernel</strong> <strong>1.B0.02</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!