Task function for RTOS (#pragma rtos_task)


The function names specified with #pragma rtos_task are interpreted as the tasks for Renesas RTOS for the RL78 family.

[Function]

-

The function names specified with #pragma rtos_task are interpreted as the tasks for RTOS.

-

A task function can be coded without arguments specified, or with only one argument of signed long type specified, but no return values can be specified.
An error will occur if two or more arguments are specified, an argument not of a signed long type is specified, or a return value is specified.

-

No function exit processing is output for the task functions for RTOS.

-

RTOS service call ext_tsk is called at the end of a task function for RTOS.

-

RTOS service call ext_tsk calls the corresponding internal function of the OS through the br !!addr20 instruction. If ext_tsk is issued at the end of a normal function, no function exit processing is output.

-

The code for the body (function definition) of a task function is output to the .text or .textf section. The section name can be changed through #pragma section.

[Effect]

-

The task function for RTOS can be described in the C source level.

-

As no function exit processing is output, the code efficiency is improved.

[Usage]

-

Specifies the function name for the following #pragma directives.

#pragma rtos_task   [(]task-function-name [ ,...][)]

[Restrictions]

-

If a task function for RTOS is specified with __inline or another type of #pragma, a compilation error will occur.

-

If a task function for RTOS is called in the same way as a normal function, a compilation error will occur.

[Example]

The following shows a sample C source code.

#pragma rtos_task       func1
#pragma rtos_task       func2
extern void ext_tsk(void);
extern void g(int *a);
 
void func1 ( void ) {
        int a[3];
        a[0] = 1;
        g(a);
        ext_tsk( );
}
 
void func2 ( signed long x ) {
        int a[3];
        a[0] = 1;
        g(a);
}
 
void func3 ( void ) {
        int a[3];
        a[0] = 1;
        g(a);
        ext_tsk( );
}
 
void func4 ( void ) {
        int a[3];
        a[0] = 1;
        g(a);
        if ( a[0] )
                ext_tsk( );
}

 

The following shows the assembly source output by compiler.

    .section        .textf, TEXTF
_func1 :
    subw    sp, #0x06             ;Stack is allocated
    onew    ax
    movw    [sp+0x00], ax         ;Assignment to an element of array a
    movw    ax, sp
    call    !!_g
    call    !!_ext_tsk            ;Function ext_tsk is called
    br      !!__kernel_task_exit  ;The epilogue for calling __kernel_task_exit is not
                                  ;output, which is always output by a task function
_func2 :
    subw    sp, #0x06
    onew    ax
    movw    [sp+0x00], ax         ;Assignment to an element of array a
    movw    ax, sp
    call    !!_g
    br      !!__kernel_task_exit  ;The epilogue for calling __kernel_task_exit is not
                                  ;output, which is always output by a task function
_func3 :
    subw    sp, #0x06
    onew    ax
    movw    [sp+0x00], ax         ;Assignment to an element of array a
    movw    ax, sp
    call    !!_g
    call    !!_ext_tsk            ;Function ext_tsk is called
    addw    sp, #0x06             ;The epilogue is output when #pragma rtos_task is 
                                  ;not specified
    ret
_func4 :
    subw    sp, #0x06
    onew    ax
    movw    [sp+0x00], ax         ;Assignment to an element of array a
    movw    ax, sp
    call    !!_g
    movw    ax, [sp+0x00]
    or      a, x
    bnz     $.BB@LABEL@4_2
.BB@LABEL@4_1:                    ;return
    addw    sp, #0x06             ;The epilogue is output when #pragma rtos_task is 
                                  ;not specified
    ret
.BB@LABEL@4_2:                    ;bb3
    call    !!_ext_tsk
    br      $.BB@LABEL@4_1