*
ITRON Specification
*
*
microITRON
*
*
Ver. 2.01.00.00
*
*
*
*
Designed by Ken Sakamura
*
*
*
*
Document number: I-01-02E-Ver.2.01.00 (File#1)
*
*
*
*
TRON ASSOCIATION
*
*
5th Floor, Katsuta Bldg., 1-3-39, Mita, Minato-ku, Tokyo 108, JAPAN
*
*
Tel +81-3-3454-3191
*
******************************************************************************
******************************************************************************
*
Copyright (c) 1990,1992 by TRON Association
*
*
*
*
The copyright of this document is reserved by TRON ASSOCIATION.
*
******************************************************************************
******************************************************************************
*
LICENSE AGREEMENT
*
*
*
* Permission to receive, use, and/or reproduce the SPECIFICATIONS which
*
* follow is granted only under the following terms and conditions.
*
* Acceptance of receipt of the SPECIFICATIONS constitutes your agreement *
* with such terms and conditions. If you do not agree with such terms
*
* and conditions, do not retrieve the SPECIFICATIONS.
*
*
*
* SECTION #1 COPYRIGHT AND OTHER PROPRIETARY RIGHTS
*
* 1.1 All copyright and other proprietary rights relating to or in
*
*
connection with the SPECIFICATIONS belong to solely the TRON
*
*
ASSOCIATION.
*
*
*
* SECTION #2 LIMITATION OF REPRODUCTION
*
* 2.1 The SPECIFICATIONS may be reproduced in their entity but any
*
*
reproduction in part is strictly prohibited.
*
*
*
* SECTION #3 COPYRIGHT NOTICES
*
* 3.1 In no event may the copyright notices or the terms and conditions *
*
of this LICENSE AGREEMENT and "Fundamental Concepts Governing the *
*
TRON Project" described on the SPECIFICATIONS be deleted.
*
* 3.2 When you reproduce the SPECIFICATION, in no event may the
*
*
copyright notices or the terms and conditions of this LICENSE
*
*
AGREEMENT and "Fundamental Concepts Governing the TRON Project"
*
*
on any copy of the SPECIFICATIONS be deleted.
*
*
*
* SECTION #4 RESTRICTION OF MODIFICATIONS
*
* 4.1 Any modification of the SPECIFICATIONS is strictly prohibited.
*
*
*
* SECTION #5 RESTRICTION OF REDISTRIBUTION
*
* 5.1 Redistributing the SPECIFICATIONS upon receipt of payment of
*
*
consideration therefor without written consent from the TRON
*
*
ASSOCIATION prior to such distribution is strictly prohibited.
*
*
*
* SECTION #6 NO WARRANTIES
*
*
*
* 6.1 The TRON ASSOCIATION disclaims all warranties with regards to the *
*
SPECIFICATIONS, including all implied warranties of
*
*
merchantability and fitness.
*
* 6.2 In no event shall the TRON ASSOCIATION be liable for any special, *
*
indirect or consequential damage or any damages or disputes
*
*
whatsoever arising out of or in connection with the use of the
*
*
SPECIFICATIONS.
*
******************************************************************************
******************************************************************************
*
Fundamental Concepts Governing the TRON Project
*
*
*
* 1. The computer architecture TRON originated by Dr.Ken Sakamura is an
*
*
open computer architecture. The TRON Specifications are made publicly *
*
available to anyone in the world.
*
*
*
* 2. Copyrights to the TRON Specifications belong to the TRON Association. *
*
Anyone is entitled to utilize the TRON Specifications in developing
*
*
and merchandizing products conforming to the TRON Specifications.
*
*
*
* 3. The TRON Association has been established as the core organization
*
*
for the purpose of preparing the TRON Specification, conducting
*
*
conformance testing, and otherwise promoting the TRON Project.
*
*
Membership in the TRON Association is open to anyone in the world who *
*
shares in the objectives of the TRON Project and agrees to observe
*
*
the TRON Association's rules.
*
*
*
*
The TRON ASSOCIATION
*
******************************************************************************
The contents of this document may be revised without prior notice.
Although the contents in this document have been carefully reviewed and is
believed to be reliable, TRON ASSOCIATION is not assuring its contents nor
assuming any liability of problems caused by this document.
TRON
BTRON
CTRON
ITRON
MTRON
is
is
is
is
is
an
an
an
an
an
abbreviation
abbreviation
abbreviation
abbreviation
abbreviation
of
of
of
of
of
****************************
* Structure of This Manual *
****************************
This manual explains uITRON specification which is the revised version of the
ITRON specification realtime operating system for microprocessors.
This manual is structured as follows:
1. Realtime Operating System and ITRON Specification overviews the necessity
for a realtime operating system and ITRON specification, and describes
ITRON1 specification, uITRON specification, and ITRON2 specification, and
their relationships.
2. uITRON Specification explains the concept of uITRON specification design,
the relationship between ITRON1 specification and uITRON specification,
and the syntax of system call specifications in later chapters.
3. System Call explains the uITRON specification system calls.
4. Programming Interface explains the system call interfaces recommended for
the uITRON specification, specifically, the function codes, error codes,
3.4
3.5
3.6
3.7
3.8
3.9
isig_sem
isnd_msg
isnd_tmb
isus_tsk
iwup_tsk
iXX_sts
mbx_sts
mpl_sts
pget_blk
pol_flg
pol_flg
prcv_msg
prcv_tmb
preq_sem
rcv_msg
rcv_tmb
rel_blk
rel_wai
ret_int
ret_rst
ret_tmr
ret_wup
rot_rdq
rsm_tsk
sem_sts
set_flg
set_flg
set_tim
sig_sem
slp_tsk
snd_msg
snd_tmb
sta_tsk
sus_tsk
ter_tsk
tmb_sts
tsk_sts
wai_flg
wai_flg
wai_sem
wai_tsk
wup_tsk
[#1]
[#2]
[#5]
[#3]
[#1]
[3B]
[4]
[4]
[3]
[3A]
[3B]
[2]
[5]
[1]
[2]
[5]
[3]
[5]
[#1]
[5]
[#4]
[3]
[3]
[3]
[4]
[3A]
[3B]
[2]
[1]
[1]
[2]
[5]
[2]
[3]
[3]
[5]
[3]
[3A]
[3B]
[1]
[3]
[1]
******************************************************************************
* Chapter 1
*
* Realtime Operating System and ITRON Specification
*
******************************************************************************
This chapter reviews the necessity for a realtime operating system and the
summary of ITRON specification, and explains ITRON1 specification, uITRON
specification, ITRON2 specification, and their relationships.
****************************************
* 1.1
*
* TRON Project and ITRON Specification *
****************************************
Since microprocessors evolved at the beginning of the 1970s, the accompanying
technology has progressed rapidly and the scope of applications is still
expanding. Microprocessors are being used everywhere and are already
the response must always be quick enough, or that the worst response time must
be predictable.
In conventional batch or TSS processing, users are waiting for available
computer time. The computer performs calculations, and there is no
relationship with other systems. Consequently, delayed processing causes
delayed results, but does not lead to catastrophe.
In realtime systems, however, calculation is not the final objective; the real
objective of the system is to control other equipment using the calculation
results. There are thus strict requirements for processing time, and if
processing is too slow, results are useless even if they are correct.
Processing delay in safety equipment control on the high-speed trains, for
example, may cause a serious accident because brakes may not operate in time.
In another system that controls the ignition timing in car engines, the
calculated timing must be given to the engine before its rotation reaches the
ignition point.
The response time is thus as important as the processing results are, and late
results mean no results.
To satisfy the strict requirements of response time, the computer must be able
to process results quickly whenever external stimuli are received. The CPU
use ratio thus drops very low. This type of computer uses never happened
until computers have become popular and their prices have dropped.
Application fields in realtime processing and embedded systems are still new.
In ordinary programming, algorithms, data structure, overall performance, and
calculation volume are usually estimated. However, the absolute program
execution time is not accurately estimated. Applications for realtime systems
require accurate estimation of execution time. They require the estimation of
response time, considering the execution status of other tasks and the load on
the entire system. Estimating the CPU time of individual programs is not
required. This estimation is extremely difficult and is impossible on the
complex operating system used on mainframes. The operating system must be
compact and simple; otherwise the overhead time cannot be estimated.
Operating systems used in embedded systems are quite different from those used
in development systems or in general data processing systems. They must have
multitasking capability and realtime characteristics.
--------------------------------------1.2.2 Advantages of ITRON specification
--------------------------------------Industrial TRON (ITRON) specification is for a realtime-multitasking operating
system to be implemented in embedded industrial systems. The standardization
or hardware virtualization is kept to a minimum to improve the processing
performance. Another important feature is that it produces compact object
code by system tuning, even though it has many functions.
Standardization and hardware virtualization are desirable from the viewpoints
of software compatibility and user training, but may cause performance
degradation. Having many functions makes programming easier and improves
performance, but the object code becomes larger. In designing an operating
system, it is necessary to balance these trade-offs, and the ITRON
specification is a good example of this. The concept of weak standardization,
which is common to the entire TRON project, has been adopted by realtime
operating systems.
In the wait state, the task cannot be executed because an execution condition
has not been satisfied. In the wait state, the task is waiting for the
condition to be satisfied.
The wait state can be further classified as the wait state, the suspend state,
or the wait-suspend state. A task enters the wait state when the task issues
a system call to itself, while waiting for an event to occur. A task enters
the suspend state when the task is suspended by another task. A task enters
the wait-suspend state when the task already in the wait state is forced to
enter the event wait state. In the ITRON specification, there is a distinct
difference between the wait and suspend states. A task cannot enter the
suspend state by itself. Resumption from the wait state begins at the point
at which the task was suspended, and environmental data such as the program
counter, registers, or other program execution status (called context) is
restored to previous value. In the wait state, the task keeps possession of
semaphores and resources other than the processor.
(4) Dormant state
In the dormant state, the task has not yet been started or has already
terminated. A task enters this state when it is created.
In this state, unlike the wait state, all the resources are released, the
context, such as the registers or program counter, is initialized at start,
and operations (wup_tsk, ter_tsk, sus_tsk, chg_pri, and other system calls)
issued to the task are treated as errors.
(5) Nonexistent state
The nonexistent state is a hypothetical state where a task is not registered
in the system; it has not been created or it has already been deleted.
The uITRON specification does not support the nonexistent state. Depending on
the implementation, it also might not support the suspend state, wait-suspend
state, or dormant state. All of states (1) to (5) are necessary in the ITRON1
and ITRON2 specifications.
One of the features of the ITRON specification is that system calls addressed
to the caller and those addressed to another task (Table 1.2) are separated to
show clearly the state transition of a task and to make the operations of
system calls easy to understand. In other words system calls for transitions
from the run state are distinguished from those for transitions from other
states.
+---------+ -------------------- Dispatch -------------------> +-------+
| READY | <------------------- Preempt -------------------- | RUN |
+---------+ <--------+ Release
Wait +------------ +-------+
| ^ ^ |
|
|
| |
| | | |
|
+----------+
|
| |
| | | |
+------- | WAIT | <-----+
| |
| | | |
|
| Terminate
| |
| | | |
+----------+ ---------------+
| |
| | | |
| ^
(ter_tsk)
|
| |
| | | |
| |
|
| |
| | | |
Suspend | | Resume
|
| |
| | | |
(sus_tsk) v | (rsm_tsk,frsm_tsk) |
| |
| | | |
+----------+
|
| |
| | | |
+---> | WAIT- | Terminate
|
| |
| | | |
|
| SUSPEND | ---------------+
| |
| | | |
+---| | | |
| | | |
| | | |
| | | | Suspend
| | | | (sus_tsk)
| | | +------------------->
| | +--------------------->
| | Resume
| | (rsm_tsk,frsm_tsk)
| |
| |
| |
| | Start (sta_tsk)
| +-----------------------+------------------------->
Terminate (ter_tsk)
+----------+ (ter_tsk)
|
| |
|
|
| |
| Release
|
| |
|
|
| |
v
|
| |
+----------+
|
| |
| SUSPEND | Terminate
|
| |
|
| ---------------+
| |
+----------+ (ter_tsk)
|
| |
|
^
|
| |
|
|
|
| |
+------+
|
| |
|
| |
+----------+
|
| |
| DORMANT | <--------------+
| |
|
| <-----------------------+ |
+----------+ Exit,abort
|
^
| (ext_tsk,abo_tsk)
|
|
|
|
Create |
| Delete
|
(cre_tsk) |
v (del_tsk)
|
+----------+
|
| NON- | Exit and delete
|
| EXISTENT | <-------------------------+
+----------+ (exd_tsk)
^
|
Initial state
|
|
Nonexistent state
|
Nonexistent state
|
+---------------------+---------------------------+-------------------------+
* In the ITRON specification, system calls addressed to the caller and those
addressed to another task are clearly separated to show clearly the state
transitions of a task and make system calls easy to understand. In other
words, system calls for transitions from the run state and those for
transitions from other states are clearly distinguished.
-----------------------1.3.1.4 Task scheduling
-----------------------Task scheduling in the ITRON specification is based on task priority. First
come first served (FCFS) scheduling applies to tasks with the same priority.
Figure 1.3 is an example of this scheduling.
Figure 1.3 (A) is the ready queue state after task A of priority 1, task E of
priority 3, and tasks B, C, and D of priority 2 have been started, in that
order. Task A has the highest priority among the current ready tasks, so
task A is executed. In the ITRON specification, the task priority is
absolute. If task A is being executed, other lower priority tasks are not
executed at all.
Here, when a system call causes task A to enter the wait state, the ready
queue at that time is as shown in Figure 1.3 (B). In this state, there are
three ready tasks with the highest priority (tasks B, C, and D). According to
the ITRON specification, if there are two or more tasks with the same
priority, the task that enters the ready state first is executed first. In
this example, task B is executed next. This method is called first come first
served (FCFS) scheduling. In the ITRON specification, FCFS scheduling applies
to tasks having the same priority.
If an external interrupt is generated in this state, rescheduling occurs on
return from the interrupt handler. However, task B is executed after the
return from the interrupt handler unless a task with higher priority than B is
placed in the ready state by the interrupt handler. That is, task B will not
lose the execution priority even if an external interrupt occurs because there
is no direct relationship between an external interrupt and the task being
executed at the point of interrupt.
However, when a task that has entered the wait or dormant state moves back to
the ready state, it is placed at the end of the ready queue of its priority.
In the ITRON specification, the rot_rdq system call rotates the ready queue of
the same priority as the task. When it is issued, task B is placed at the end
of the ready queue.
The user can apply round-robin scheduling to tasks having the same priority,
rather than using FCFS scheduling. Round-robin scheduling gives each task a
time slice of the processor. To implement the scheduling, the following two
steps are needed: (1) Activate the interrupt handler at fixed-time intervals
using timer interrupts. (2) Issue the rot_rdq system call.
A task priority can be changed dynamically by the chg_pri system call.
Head of ready queue
+-----------------+
|
----------------+
+-----------------+
|
|
Priority
High
^
|
|
|
|
|
|
|
v
Low
Priority 1
Priority 2
Priority 3
|
+----> Task A ---->---+
|
+---------------------+
|
+----> Task B ----> Task C ----> Task D ----+
|
+-------------------------------------------+
|
+----> Task E ---->
Transient statuses
(operating system
(being executed)
Task-independent
portion being executed
(interrupt handlers)
Quasi-task portion being
executed
(Extended SVC handlers)
specification.
By contrast, the quasi-task portion consists mainly of the user-expanded parts
of the operating system. These include the extended SVC handlers.
Some processors, however, do not have a quasi-task portion, and the extended
SVC handler is contained in the task-independent portion.
The quasi-task portion identifies the task that was being executed immediately
before the quasi-task portion was entered (requesting task). The quasi-task
portion defines the task status in the same way as in the task portion, and it
can enter the wait state. Hence, dispatching occurs in the quasi-task portion
in the same way as in a usual task execution. As a result, a quasi-task
portion, such as the expanded portion of an operating system, is not always
executed prior to all other tasks even though it belongs to the non-task
portion, in contrast to the interrupt handler, which is always executed prior
to all other tasks.
The following two examples show the differences between task-independent
portions and quasi-task portions:
- An interrupt occurred during execution of task A (priority 8 (low)), and
wup_tsk was executed for task B (priority 2 (high)) by the interrupt handler
(task-independent portion). However, in accordance with the delayed
dispatching principle, dispatching does not yet occur; wup_tsk is executed,
then the remaining part of the interrupt handler is executed. Dispatching
is eventually caused by ret_int placed at the end of the interrupt handler,
and then task B is executed.
- An extended system call was executed during task A (priority 8 (low)), and
wup_tsk was executed for task B (priority 2 (high)) in the extended SVC
handler (quasi-task portion). However, because the delayed dispatching
principle does not apply, dispatching occurs during wup_tsk, task A enters
the ready state of the quasi-task portion, and task B enters the run state.
Hence, task B is executed before the remaining part of the extended SVC
handler. When dispatching occurs again and task A enters the run state, the
remaining part of the extended SVC handler is executed.
| : Task-independent portion
! : Task portion
Task A
Task B
Interrupt X
Interrupt Y
(low priority) (high priority)
(low priority)
(high priority)
!
!
Interrupt !--------------------------------->|
|
Interrupt +------------------->|
nesting
|
wup_tsk B
|
|
2 +<--------------ret_int 1
|
|
wup_tsk C
|
|
4 !<---------------ret_int 3
!
************************************
This section explains the uITRON and ITRON2 specifications.
--------------------------------------1.4.1 Overview of uITRON specification
--------------------------------------Standard operating systems have seldom been used in single-chip computers used
in electrical appliances and automobiles. This is because of the limited ROM
and RAM capacity. Instead, operating system functions have been included in
the application program. The uITRON specification OS is a standard operating
system for these applications. Its adaptability minimizes memory overhead and
degraded performance.
------------------------------------------------1.4.1.1 Basic philosophy of uITRON specification
------------------------------------------------Semiconductor manufacturers have recently introduced 8-bit and 16-bit
processors using their own architectures. Those processors are to be
incorporated in single-chip computers or application-specific integrated
circuits (ASICs). Since these processors are often used in realtime and
embedded-system applications, there are many demands to implement the ITRON
specification as the standard operating system.
The ITRON1 specification was designed for general-purpose 16-bit processors.
There are too many functions to be implemented on single-chip computers or
8-bit processors, and these processors often do not have enough ROM or RAM.
In the ITRON specification, functions can be deleted. This does not mean that
any function can arbitrarily be deleted by the user, but means that function
subsets and tuning for individual applications are provided. Because
compatibility is lost if there are functions not supported by the operating
system, the minimum functions required for implementation have been determined
for the ITRON specification.
To form a function subset for an application, the user may want to delete
parts of functions. For example, because the ITRON specification semaphore is
a counting type, the wait semaphore (wai_sem) system call permits the resource
count to be specified, using the cnt parameter. To delete only the variable
resource count, the resource count is fixed to 1, thus eliminating the cnt
parameter. In the same way, if the time-out function in the wait semaphore is
deleted, the tmout parameter, which specifies time-out, is not needed.
Deleting parameters saves ROM and RAM space. This is an important factor for
single-chip computers.
However, the presence or absence of parameters affects the system
interfaces. Parameters cannot be deleted arbitrarily by the user
compatibility with a high-level language is necessary. The ITRON
specification provides tuning for applications; however unlimited
not permitted so that compatibility with high-level languages is
call
when
tuning is
maintained.
stipulate necessary functions and system calls. For this reason, the main
objective of this specification is to set up guidelines for determining the
correspondence between system call names and functions. The uITRON
specification has two necessary functions:
1 There are three task states: run, ready, and wait (multitasking operating
system).
Depending on the implementation, the dormant and suspend states may also be
used.
2 An implementation-specific interrupt handler can be defined.
Tasks may wake up when the interrupt handler issues a system call (realtime
operating system).
The interrupt handler may be defined statically (at system generation or
initialization) or by the def_int system call.
For example, a uITRON specification operating system may have only two system
calls: the sleep task (slp_tsk) system call that places a task in the wait
state, and the wakeup task (wup_tsk) or return and wakeup task (ret_wup)
system call, issued by the interrupt handler, that wakes up a task in the wait
state.
A uITRON specification operating system does not guarantee that specific
functions are available to users. Conformity to the uITRON specification
simply assures the correspondence between system call names and functions.
In other words, it is easy to find out which system call should be used to
obtain a certain function or what a system call is doing in a program. This
"training compatibility" is extremely important in programming for embedded
systems.
--------------------------------------1.4.2 Overview of ITRON2 specification
--------------------------------------The ITRON2 specification is a higher level version of the ITRON1
specification, assuming that the ITRON specification is implemented on a
32-bit processor.
------------------------------------------------1.4.2.1 Basic philosophy of ITRON2 specification
------------------------------------------------The major purpose of the ITRON2 specification is improvement of the
compatibility between ITRON specification operating systems and the
portability of application programs. The following points have been added to
the conventional ITRON specification philosophy during the design stage.
- Higher standardization level
Responding to improved performance of processors, compatibility levels are
raised by widening the scope of standardization. For example, standard
specifications are available for the exception management functions, which
have been processor-dependent. However, virtualization is not adopted in
the ITRON2 specification, and the best performance policy still continues to
be as in the ITRON1 specification.
- Integration as the TRON specification family
Consistency of names and terminology is stipulated among BTRON, CTRON, and
ITRON specifications.
- System call classes
The ITRON2 specification has quite a few more functions than the ITRON1
specification. For ease of user understanding and migration from the ITRON1
specification, the system calls have been divided into three classes: basic
functions (I1), extended functions (I2), and system operation functions.
The class I1 functions are almost the same as those in the ITRON1
specification.
-----------------------------------1.4.2.2 ITRON2 specification design
-----------------------------------This section explains the concepts of the ITRON2 specification design and the
differences between ITRON1 and ITRON2 specifications.
- System call splitting and naming
Each generic function given to a system call in the ITRON1 specification is
now split into several primitive system calls in the ITRON2 specification.
This improves compatibility with the uITRON specification, reduces system
call options, adds functions, and provides flexibility in selection of
system calls.
For the names of split system calls, it is desirable to retain the original
names. However, it is difficult to assign a name as in the conventional
format of xxx_yyy.
Therefore, eight-character system call names, zxxx_yyy, are added to the
conventional format (xxx_yyy). The xxx and yyy parts represent the
operation and object, as in the conventional form, and the prefix z
indicates that the name is a derivative.
- Object access method
Unlike for ITRON1, the ITRON2 specification does not allow object accesses
to use access keys obtained dynamically during object creation; values (ID
number, for example) established before execution should be used. This
makes it easier to write programs and improves compatibility.
- Exception management
Specifications such as exception classification, nested activation of
exception handlers, and exception management in extended SVC handlers have
been clarified, and standardization has been improved for exception
processing programs.
Exception handlers in another task can be activated by software. This
function is named "forced exception" and is classified as a class I2
function in the ITRON2 specification. The exit processing routine in the
ITRON1 specification is treated as an exception handler (exit handler) in
the ITRON2 specification.
******************************************************************************
* Chapter 2
*
* uITRON specification
*
******************************************************************************
This chapter explains the concept of the uITRON specification design, the
relationship between ITRON1 specification and uITRON specification, and the
syntax of the system call specifications in later chapters.
******************
* 2.1
*
* Design Concept *
******************
Semiconductor manufacturers have recently introduced 8-bit and 16-bit
processors using their own architectures. Those processors are to be
incorporated in single-chip computers or application-specific integrated
circuits (ASICs). Since these processors are often used in realtime and
embedded-system applications, there are many demands to implement the ITRON
specification as the standard operating system.
The ITRON1 specification was designed for general-purpose 16-bit processors.
There are too many functions to be implemented on single-chip computers or
8-bit processors, and these processors often do not have enough ROM or RAM.
In the ITRON specification, functions can be deleted. This does not mean that
any function can arbitrarily be deleted by the user, but means that function
subsets and tuning for individual applications are provided. Because
compatibility is lost if there are functions not supported by the operating
system, the minimum functions required for implementation have been
determined for the ITRON specification. Figure 2.1 shows the tuning concept
in the ITRON specification.
To form a function subset for an application, the user may want to delete
parts of functions. For example, because the ITRON specification semaphore is
a counting type, the wait semaphore (wai_sem) system call permits the resource
count to be specified, using the cnt parameter. To delete only the variable
resource count, the resource count is fixed to 1, thus eliminating the cnt
parameter. In the same way, if the time-out function in the wait semaphore is
deleted, the tmout parameter, which specifies time-out, is not needed.
Deleting parameters saves ROM and RAM space. This is an important factor for
single-chip computers.
However, the presence or absence of parameters affects the system call
interfaces. Parameters cannot be deleted arbitrarily by the user when
compatibility with a high-level language is necessary (See Figure 2.2).
The ITRON specification provides tuning for applications; however unlimited
tuning is not permitted so that compatibility with high-level languages is
maintained.
Function in the ITRON specification
+------------+-------+-------+-------+--------+-------+
|
Task
| Event | Sema- | Mail- | Memory | Other |
| management | flag | phore | box | pool |
|
+-----------------------------------------------------+
|
| Affected by processor architecture
|
v
Function implemented on the OS for the iAPX86
+------------+-------+-------+-------+--------+-------+ - - - - - - - - - -+
|
Task
| Event | Sema- | Mail- | Memory | Other | Processor|
| management | flag | phore | box | pool |
| dependent functions|
+-----------------------------------------------------+ - - - - - - - - - -+
Function implemented on the OS for the MC68000
+------------+-------+-------+-------+--------+-------+ + - - - - - - - - - +
|
Task
| Event | Sema- | Mail- | Memory | Other | |Processor|
| management | flag | phore | box | pool |
|-|dependent functions|
+-----------------------------------------------------+ + - - - - - - - - - +
for application C
+ - - - +
+ - - - - - - - - - +
| Mail- |
|Processor|
| box |-------------------|dependent functions|
- - - - +
+ - - - - - - - - - +
+----------------------------------------------------------------------------+
|wai_sem interface when resource acquisition count and time-out specification|
|are not required
|
+----------------------------------------------------------------------------+
ercd = wai_sem (a_sem);
a_sem: Semaphore access key (semaphore ID number)
ercd: Error code
* When compatibility in a high-level language is required, parameters
cannot be deleted even if they are not needed.
Figure 2.2 Example of wait semaphore (wai_sem) system call interface
The uITRON specification is an architecture provided to overcome the tuning
limits set on the ITRON specification adaptability. In other words, the ITRON
specification places emphasis on standardization rather than tuning, while the
uITRON specification place emphasis on tuning rather than standardization.
This means that even 8-bit processors in single-chip microcomputers, where RAM
This means that all programs must be reviewed and corrected for program
migration.
The advantages of standardization by the use of the uITRON specification
include ease of training and consistent system call names and functions.
Reduced programmer training costs and increased program productivity are
strong motives for standardization. As stated above, programs often need to
be rewritten in applications of the uITRON specification, which means that
reduction of the training costs is more important than program portability.
Converting a uITRON specification OS application program to another processor
is easy because the one-to-one correspondence of the name and function of each
system call is maintained between the source and target system of the
conversion. Understanding either the ITRON specification or uITRON
specification makes it easier to understand the other.
The uITRON specification is used as a guideline for designing operating
systems and naming system calls. The uITRON specification provides a separate
specification for each processor or application, following a single guideline.
It can be considered as a set of operating systems covering many
specifications for different operating systems. Conforming to the uITRON
specification signifies that the system call names determined by the uITRON
specification are used.
The following sections give details of the uITRON specification design, and
explain the implications of standardization in the uITRON specification.
********************************
* 2.2
*
* uITRON Specification Design *
********************************
The uITRON specification is basically a subset of the functions determined by
the ITRON specification, and many implementation-dependent specifications are
permitted. The uITRON specification system call names and interfaces are not
always the same as those of ITRON specifications. Changes were made because
adopting a subset of the ITRON specifications creates unbalanced functions or
wasteful parameters for unsupported functions. The fundamental design
philosophy is to simplify specifications in order to gain high performance.
The following sections explain the concept of uITRON specification design and
differences between the ITRON and uITRON specifications.
----------------2.2.1 Task states
----------------Like the ITRON specification, the uITRON specification is for a realtime
operating system that performs preemptive scheduling. As in the ITRON
specification, a task having a smaller priority number takes priority over one
having a greater number.
Unlike the ITRON specification, however, the uITRON specification does not
support dynamic creation of objects, such as tasks and semaphores. It
therefore has no task state corresponding to the nonexistent state in the
ITRON specification. The uITRON specification has five states as follows:
(1) Run state
In the run state, a task is being executed.
+-----------------------> |
| <------------------+
Terminate (ter_tsk)
+----------+ Exit (ext_tsk)
v
---
*
*
*
*
This is not a major problem in the ITRON specification, but, in the uITRON
specification where RAM space should ideally be reduced, it makes
implementing the queuing function difficult. In the uITRON specification,
the multiple-queuing function for the wup_tsk and sus_tsk system calls is
implementation-dependent, so implementations having single queueing are
permitted.
- Time-out
The ITRON specification permits specifying time-out for system calls which
enter the wait state, but the uITRON specification does not as implementing
the time-out processing may increase the implementation workload.
- Event flags
The ITRON specification treats 16 to 32 event flag bits as a word to permit
an OR or AND operation on the specified bits. Use of these functions,
however, requires many parameters to issue system calls for event flag
operations, thus causing performance degradation and memory shortage.
The uITRON specification permits single-bit event flag operations as an
alternative implementation. The single-bit operations form a subset of the
event flag word operations. Figure 2.5 shows the parameters and return
parameters used for single-bit and word operations.
+-----------------------+
| Single-bit event flag |
+-----------------------+
System call
Parameter
Return parameter
----------- ------------------------- ---------------wai_flg
flgid
Clear not specified
cwai_flg
flgid
Clear specified
+-----------------+
| Word event flag |
+-----------------+
System call
Parameter
Return parameter
----------- --------------------------- ---------------wai_flg
flgid
waiptn
wfmode
flgptn
flgid:
waiptn:
wfmode:
flgptn:
The uITRON specification uses eight-character system call names of the format
zxxx_yyy in addition to the conventional format xxx_yyy. The xxx and yyy
parts have the conventional meanings of operation and object, while z
indicates that the system call has been derived from the original system call.
Within the entire TRON specification, the zxxx_yyy form is used for complex
system calls in the ITRON specification and for shell system calls in the
BTRON specification.
The following uITRON specification functions have been split into their
primitive functions:
- Polling functions
For resource acquisition system calls in the ITRON1 specification,
time-out = 0 must be set to avoid entering the wait state when a resource
cannot be allocated. Normal termination indicates that the resource has
been acquired, and a time-out error indicates that it has not been acquired.
It can be said that the ITRON1 specification has only one system call for
resource acquisition, polling, and time-out functions.
For the three primitive functions mentioned above, the time-out function has
been removed from the uITRON specification. The primitive system calls for
resource acquisition have the same name as in the ITRON1 specification, and
the system call for polling is prefixed by p.
For example, the receive message (rcv_msg) system call, which waits to
receive a message, is provided in both ITRON1 and uITRON specifications.
The task that issued this system call enters the wait state if the message
has not been received. To avoid this, time-out (tmout) can be set to 0, and
for the ITRON1 specification, the same rcv_msg system call can be executed,
while for the uITRON specification, the poll and receive message (prcv_msg)
system call can be executed.
The following system calls execute polling:
preq_sem Equivalent to wai_sem with tmout = 0
prcv_msg Equivalent to rcv_msg with tmout = 0
pget_blk Equivalent to get_blk with tmout = 0
The get object status (xxx_sts) system call is provided as a function
similar to polling, to examine the object or resource status. xxx_sts,
however, does not acquire any resource even if several resources are
available; it merely examines whether a resource is available. Polling
however, acquires a resource if it is available. Thus, examining the object
status and resource polling differ.
- System calls issued by task-independent portion
The ITRON1 specification does not distinguish between system calls issued by
tasks and those issued by the task-independent portion (interrupt handlers).
Dispatch requests generated in an interrupt handler are delayed until the
system escapes from the interrupt handler (the principle of delayed
dispatching). This means that processing inside the operating system
depends on whether a task or an interrupt handler issued the system call.
Since there is no distinction between the two, the operating system
determines the caller from the context where the system call was issued.
Conversely, the uITRON specification has separate system calls to be issued
by task-independent portions (interrupt handlers) and by tasks. This
removes overhead for the context determination by the operating system, and
- Error codes
The uITRON specification has weakly standardized specifications for error
mnemonics and error code values.
Generally, standardized error codes do not affect the performance or object
size. However, precise specification of the error checking or the detection
priority of multiple errors may set restrictions on the implementation and
affect the performance. Hence, the uITRON specification proposes weakly
standardized error codes, and there are no detailed specifications for error
checking.
To reinforce consistency with BTRON and ITRON2 specifications, the uITRON
specification uses negative numbers as standard error codes. The ITRON2 and
uITRON specifications use the same standard values.
- Negative numbers
All of the TRON specification family use negative numbers for the operating
system and positive numbers for applications. The number 0 is for special
uses. The following gives examples of how these numbers are used:
- In the ITRON specification, tskid = 0 indicates the caller task.
- In the ITRON/MMU specification, spcid = (-1) indicates shared space.
- In the BTRON specification, a negative value returned from system call
indicates an error.
- In the BTRON specification, process_id = 0 indicates the caller process,
and process_id = (-1) indicates the parent process.
- In the TRON-architecture microprocessor specification, negative addresses
are shared semispace (SS) and positive addresses are unshared semispace
(US).
- In the CTRON specification, tmout = (-1) indicates no time-out.
In the uITRON specification, strict restrictions of individual processor
architectures make it difficult to apply these general rules. However, they
should be applied wherever possible in giving object ID numbers and
priority, as long as the performance does not decline. For example, to
provide I/O tasks together with the kernels, it is better the task ID number
is a signed number so that a negative ID number (for example, from -8 to -5)
indicates an I/O task.
Even for weak standardization items stated above, it is necessary to identify
which parameters in an implementation are different from the standard uITRON
specification parameters. Clarifying where to modify by the implementor is
absolutely necessary for program portability.
Some processors provide register-bank switching or special functions such as a
low-power mode in the idle state. These functions should be incorporated in
the uITRON specification. To support these optional functions, the uITRON
specification gives a range of function codes to these processor- or
implementation-dependent system calls.
**********************************
* 2.4
*
* Scope of uITRON Specification *
**********************************
As stated above, the uITRON specification is for an operating system having
many implementation-dependent functions. The explanations of uITRON
is tmb.
- Task restart function
The task restart function restarts the specified task from the specified
address when control returns from interrupt processing. As viewed from the
task to be restarted, this function is a sort of exception processing
(forced exception by software). To simplify the specifications and achieve
a higher speed, the uITRON specification handles it separately from
exception processing.
This function can be used to return the program control to a checkpoint for
fault tolerance.
- Other
For the uITRON specifications to keep pace with future semiconductor
technology progress, the functions must be simplified and the specifications
made flexible so that the simplified functions can be expanded. Because the
ITRON1 and ITRON2 specifications are upper levels of the uITRON
specification, expanded uITRON specification functions should conform to
ITRON1 and ITRON2 specifications. The uITRON specification is not for a
single operating system, but can be considered as a guideline to how far
away from the ITRON1 and ITRON2 specifications it can be.
The following sections explain the standard uITRON specification system
calls, but they do not set the upper limits of functions in the uITRON
specification. System calls not listed in this specification can be added.
However, if added functions are supported by the ITRON2 specification,
system call names or system call interfaces must be consistent with those in
the ITRON2 specification.
************************************
* 2.6
*
* System Call Specification Syntax *
************************************
Chapter 3 explains the specifications for each system call in the following
syntax:
****************************
* [level] System call name *
* Function
*
****************************
* A number [level] indicates the level of implementation. Number 1 signifies
one of the most important functions, and higher numbers suggest the
possibility of deletions from each implementation.
* A number in [level] suffixed by A or B indicates that it is up to
implementor whether to use specification A or B.
* A number in [level] suffixed by # indicates that the system call can be
substituted by another method. For example, def_int is suffixed by #
meaning that a substitution for the interrupt handler (for example, static
definition at operating system initialization) makes this system call
unnecessary.
[Parameter]
This section explains the system call parameters to be passed to the uITRON
specification OS when the system call is issued.
[Return parameter]
This section explains the system call return parameters (except error
conditions) to be returned from the uITRON specification OS when the system
call execution is completed.
[Description]
This section explains the function of the system call.
* The following notation is used to express multiple choices:
(x || y || z) x, y, or z
x | y
x or y or both
(If both are specified, logical OR of x and y is used.)
[x]
x or none
Example:
wfmode := (TWF_ANDW || TWF_ORW)|[TWF_CLR] specifies that
wfmode be one of the four possible parameters listed below.
TWF_ANDW
TWF_ORW
(TWF_ANDW | TWF_CLR)
(TWF_ORW | TWF_CLR)
* The uITRON specification permits part of the functions described in
Description to be implemented. This must be explicitly written in the
manual. If an unsupported function of a system call is used, the E_NOSPT
error code is returned.
* In Description, an assumption is made that no interrupt occurs during
execution of a system call, nor causes the same object to be manipulated.
Suppose that an interrupt occurs during or immediately before or after a
system call is executed. Then, the system call function may have too many
cases to be explained. For example, an explanation might state that the
resource count becomes four when the sig_sem (rcnt=1) system call is issued
to a semaphore with resource count = 3. This explanation is incorrect if an
interrupt occurs during system call execution and sig_sem is executed.
Description explains the operation with the assumption that no interrupt
occurs during execution.
[Error codes]
This section explains errors that may occur during system call execution.
* The following error codes are for errors which are common to each system
call. They are not written in the specifications of individual system
calls.
E_SYS
E_RSFN
E_CTX
E_NOSPT
Error with unknown cause, which may affect the entire system
Error occurring if a reserved function code number is specified
Context error indicating that the context does not match the system
call (task/task-independent portion and handler execution status)
For a system call which possibly generates a context error, this
code appears in the error code explanation of the system call.
In the ITRON2 and uITRON specifications, implementation- dependent
system calls can be issued from the task-independent portion.
If such a system call is issued in the implementation which does not
support the context, the E_CTX or E_XNOSPT error code is also
returned.
Error occurring if an unsupported function is specified. The uITRON
specification permits part of the system call functions to be
implemented, so partial implementation of a system call may cause
this error.
* The uITRON specification does not detail error checking to avoid heavy
restrictions on the implementation and performance degradation. Therefore,
standard error codes are proposed, and those codes given in this section
need not be strictly followed. Depending on the implementation, some error
codes might not be supported, or error codes other than the standard code
might be supported, or error-detection conditions might differ slightly.
* The error codes in this
mean that all the codes
implementation or error
E_TNOSPT does not occur
******************************************************************************
*
ITRON Specification
*
*
microITRON
*
*
Ver. 2.01.00.00
*
*
*
*
Document number: MI-10-01-E (File#1)
*
******************************************************************************