- 212 -
#include
<itron.h>
#include
<kernel.h>
#include "kernel_id.h"
void task(void)
{
for(;;){
/*
process
*/
}
}
Figure 7.2 Example Task Terminating with ext_tsk() Described in C Language
7. To specify a task, use the string written in the task definition item “name” of the configura-
tion file.
wup_tsk(ID_main);
8. To specify an event flag, semaphore, or mailbox, use the respective strings defined in the
configuration file.
For example, if an event flag is defined in the configuration file as shown below,
flag[1]{
name
=
ID_abc;
};
To designate this eventflag, proceed as follows.
set_flg(ID_abc,&setptn);
9. To specify a cyclic or alarm handler, use the string written in the cyclic or alarm handler
definition item “name” of the configuration file.
sta_cyc(ID_cyc);
10. When a task is reactivated by the sta_tsk() service call after it has been terminated by the
ter_tsk() service call, the task itself starts from its initial state.
riable and static variable are not automatically initialized when the task is started. The ex-
ternal and static variables are initialized only by the startup program (crt0mr.a30), which
actuates before MR100 startup.
11. The task executed when the MR100 system starts up is setup.
12. The variable storage classification is described below.
The MR100 treats the C language variables as indicated in Table 7.1 C Language Variable Treatment.
Table 7.1 C Language Variable Treatment
Variable storage class
Treatment
Global Variable
Variable shared by all tasks
Non-function static variable
Variable shared by the tasks in the same file
Auto Variable
Register Variable
Static variable in function
Variable for specific task
7.1.2
Writing a Kernel (OS Dependent) Interrupt Handler
When describing the kernel interrupt handler in C language, observe the following precautions.
41
The configurator generates the file “kernel_id.h” that is used to convert the ID number of a task into the string to be specified. This means
that the #define declaration necessary to convert the string specified in the task definition item “name” into the ID number of the task is
made in “kernel_id.h.” The same applies to the cyclic and alarm handlers.
42
The task starts from its start function with the initial priority in a wakeup counter cleared state.