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.

2.2. TASK STATES AND SCHEDULING RULES 7<br />

(e) NON-EXISTENT state<br />

A virtual state before a task is created, or after it is deleted, and is not registered in the system.<br />

Depending on the implementation, there may also be transient states that do not fall into any of the<br />

above categories (see section 2.5 on page 12).<br />

When a task going to READY state has higher precedence than the currently running task, a dispatch<br />

may occur at the same time as the task goes to READY state and it may make an immediate transition<br />

to RUN state. In such a case the task that was in RUN state up to that time is said to have<br />

been preempted by the task newly going to RUN state. Note also that in explanations of system call<br />

functions, even when a task is said to go to READY state, depending on the task precedence it may go<br />

immediately to RUN state.<br />

Task starting means transferring a state from DORMANT state to READY state. A task is therefore<br />

said to be in “started” state if it is in any state other than DORMANT or NON-EXISTENT. Task exit<br />

means that a task in started state goes to DORMANT state.<br />

Task wait release means that a task in WAIT state goes to READY state, or a task in WAIT-SUSPEND<br />

state goes to SUSPEND state. The resumption of a suspended task means that a task in SUSPEND<br />

state goes to READY state, or a task in WAIT-SUSPEND state goes to WAIT state.<br />

Task state transitions in a typical implementation are shown in Figure 2.1.<br />

Depending on the implementation, there may be other states besides those shown here.<br />

A feature of T-<strong>Kernel</strong> is the clear distinction made between system calls that perform operations affecting<br />

the invoking task and those whose operations affect other tasks (see Table 2.1). The reason for this is<br />

to clarify task state transitions and facilitate understanding of system calls. This distinction between<br />

system call operations in the invoking task and operations affecting other tasks can also be seen as a<br />

distinction between state transitions from RUN state and those from other states.<br />

Additional Note<br />

WAIT state and SUSPEND state are orthogonally related, in that a request for transition to SUSPEND<br />

state cannot have any effect on the conditions for task wait release. That is, the task wait release<br />

conditions are the same whether the task is in WAIT state or WAIT-SUSPEND state. Thus even<br />

if transition to SUSPEND state is requested for a task that is in a state of waiting to acquire some<br />

resource (semaphore resource, memory block, etc.), and the task goes to WAIT-SUSPEND state, the<br />

conditions for allocation of the resource do not change but remain the same as before the request to go<br />

to SUSPEND state.<br />

Rationale for the <strong>Specification</strong><br />

The reason the T-<strong>Kernel</strong> specification makes a distinction between WAIT state (wait caused by the<br />

invoking task) and SUSPEND state (wait caused by another task) is that these states sometimes overlap.<br />

By distinguishing this overlapped state as WAIT-SUSPEND state, the task state transitions become<br />

clearer and system calls are easier to understand. On the other hand, since a task in WAIT state cannot<br />

invoke a system call, different types of WAIT state (e.g., waiting for wakeup, or waiting to acquire a<br />

semaphore resource) will never overlap. Since there is only one kind of wait state caused by another<br />

task (SUSPEND state), the T-<strong>Kernel</strong> specification treats overlapping of SUSPEND states as nesting,<br />

thereby achieving clarity of task state transitions.<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!