CHAPTER 6 TASK EXCEPTION HANDLING FUNCTIONS
When task exception is requested to a task, the task exception handling routine defined for the task is invoked. The requested exception code is passed to the task exception handling routine.
Exception handling according to the requested exception code should be implemented in a task exception handling routine.
Note 3 These statements are unnecessary for the task exception handling routine which is created by the system configuration file because the cfg600px generates these statement into the "kernel_id.h".
- FPSW register when processing is started
When setting of Task context register (context) in System Information (system) includes "FPSW", the FPSW when processing is started is shown in Table 6-3. The FPSW when processing is undefined in other cases.
When setting of Task context register (context) in System Information (system) includes "FPSW", the FPSW when processing is started is shown in Table 6-3. The FPSW when processing is undefined in other cases.
When all the following conditions are fulfilled about a task which is scheduled according to "16.4 Task Scheduling Method", the RI600PX starts the task exception handling routine in stead of the task itself. When the task exception handling routine is finished, execution of the task itself is resumed.
When task exception is requested by ras_tex or iras_tex, the pending exception code for the corresponded task is renewed to the logical add with specified exception code.
Tasks are in one of the state of task exception disabled state or task exception enabled state. Immediately after starting tasks, the task is in task exception disabled state. And the task is in task exception disabled state while the task exception handling routine is not defined. When ena_tex is called, the invoking task enters in task exception enabled state. When dis_tex is called, the invoking task enters in task exception disabled state.
When the task exception handling routine is started, the task enters in task exception disabled state. When the task exception handling routine is finished, the task enters in task exception enabled state.
1 ) Definition by the system configuration file
The task exception handling routine can be defined by the static API "task[]", which creates a task, described in the system configuration file.
Refer to "20.10 Task Information (task[])" for the details of "task[]".
The task exception handling routine can be defined by the static API "task[]", which creates a task, described in the system configuration file.
Refer to "20.10 Task Information (task[])" for the details of "task[]".
2 ) Definition by def_tex
The def_tex defines a task exception handling routine for the task indicated by parameter tskid according to the content of parameter pk_dtex.
The information specified is shown below.
The def_tex defines a task exception handling routine for the task indicated by parameter tskid according to the content of parameter pk_dtex.
The information specified is shown below.
This service call can be called from tasks that belong to Trusted Domain.
The following describes an example for coding def_tex.
The following describes an example for coding def_tex.
#include "kernel.h" /*Standard header file definition*/ #include "kernel_id.h" /*Header file generated by cfg600px*/ extern void Texrtn1 ( TEXPTN texptn, VP_INT exinf ); #pragma task Task1 /*Refer to note*/ void Task1 (VP_INT exinf); /*Refer to note*/ void Task1 (VP_INT exinf) { ER ercd; /*Declares variable*/ ID tskid = TSK_SELF; /*Declares and initializes variable*/ T_DTEX pk_dtex = { /*Declares and initializes variable*/ TA_HLNG, /*Task exception handling routine attribute (texatr)*/ (FP)Texrtn1 /*Start address (texrtn)*/ }; /* ......... */ ercd = def_tex ( tskid, &pk_dtex ); /*Define task exception handling routine*/ /* ......... */ } |
Note These statements are unnecessary for the task which is created by the system configuration file because the cfg600px generates these statement into the "kernel_id.h".
When NULL is specified as parameter pk_dtex in the def_tex, the def_tex cancels a definition of the task exception handling routine for the task indicated by parameter tskid.
The def_tex can be called from tasks that belong to Trusted Domain.
The following describes an example for coding to cancel the a definition of the task exception handling routine by using def_tex.
The following describes an example for coding to cancel the a definition of the task exception handling routine by using def_tex.
.
#include "kernel.h" /*Standard header file definition*/ #include "kernel_id.h" /*Header file generated by cfg600px*/ #pragma task Task1 /*Refer to note*/ void Task1 (VP_INT exinf); /*Refer to note*/ void Task1 (VP_INT exinf) { ER ercd; /*Declares variable*/ ID tskid = TSK_SELF; /*Declares and initializes variable*/ /* ......... */ ercd = def_tex ( tskid, (T_DTEX *)NULL ); /*Cancel a definition*/ /* ......... */ } |
Note These statements are unnecessary for the task which is created by the system configuration file because the cfg600px generates these statement into the "kernel_id.h".
- ras_tex, iras_tex
These service calls requests task exception handling for the task indicated by parameter tskid. The task pending exception code for the task is ORed with the value indicated by parameter rasptn.
When all the conditions described in "6.2.3 The starting conditions of task exception handling routines" are fulfilled by this service call, the RI600PX starts the task exception handling routine.
The following describes an example for coding this service call.
These service calls requests task exception handling for the task indicated by parameter tskid. The task pending exception code for the task is ORed with the value indicated by parameter rasptn.
When all the conditions described in "6.2.3 The starting conditions of task exception handling routines" are fulfilled by this service call, the RI600PX starts the task exception handling routine.
The following describes an example for coding this service call.
#include "kernel.h" /*Standard header file definition*/ #include "kernel_id.h" /*Header file generated by cfg600px*/ #pragma task Task1 /*Refer to note*/ void Task1 (VP_INT exinf); /*Refer to note*/ void Task1 (VP_INT exinf) { ID tskid = 8; /*Declares and initializes variable*/ TEXPTN rasptn = 0x00000001UL; /*Declares and initializes variable*/ /* ......... */ ras_tex ( tskid, rasptn ); /*Request task exception*/ /* ......... */ } |
Note These statements are unnecessary for the task which is created by the system configuration file because the cfg600px generates these statement into the "kernel_id.h".
The dis_tex disables task exception for the invoking task, and the ena_tex enables task exception for the invoking task.
#include "kernel.h" /*Standard header file definition*/ #include "kernel_id.h" /*Header file generated by cfg600px*/ #pragma task Task1 /*Refer to note*/ void Task1 (VP_INT exinf); /*Refer to note*/ void Task1 (VP_INT exinf) { /* ......... */ ena_tex (); /*Disable task exception*/ /* ......... */ /*Task exception enabled state*/ dis_tex (); /*Enable task exception*/ /* ......... */ } |
Note These statements are unnecessary for the task which is created by the system configuration file because the cfg600px generates these statement into the "kernel_id.h".
It may be necessary to refer to task exception disabled state for the task of a calling agency in functions that are called from two or more tasks and handlers. In this case, sns_tex is useful.
- sns_tex
This service call returns TRUE when the task in the RUNNING state is in the task exception disabled state, and when other, this service call returns FALSE.
The following describes an example for coding this service call.
This service call returns TRUE when the task in the RUNNING state is in the task exception disabled state, and when other, this service call returns FALSE.
The following describes an example for coding this service call.
#include "kernel.h" /*Standard header file definition*/ #include "kernel_id.h" /*Header file generated by cfg600px*/ void CommonFunc ( void ); void CommonFunc ( void ) { BOOL ctx; /*Declares variable*/ BOOL tex; /*Declares variable*/ /* ......... */ ctx = sns_ctx ( ); /*Reference context type*/ if (ctx == TRUE ) { /* ......... */ /*Processing for non-task context*/ /* ......... */ } else if ( ctx == FALSE ) { /* ......... */ /*Processing for task context*/ /* ......... */ tex = sns_tex (); /*Reference task exception disabled state*/ if ( tex == TRUE) { /* ......... */ /*The invoking task is in the task*/ /* ......... */ /*exception disabled state.*/ } else if ( tex == FALSE) { /* ......... */ /*The invoking task is in the task*/ /* ......... */ /*exception enabled state.*/ } } /* ......... */ } |
- ref_tex, iref_tex
Stores task exception state packet of the task specified by parameter tskid in the area specified by parameter pk_rtex.
The following describes an example for coding these service calls.
Stores task exception state packet of the task specified by parameter tskid in the area specified by parameter pk_rtex.
The following describes an example for coding these service calls.
#include "kernel.h" /*Standard header file definition*/ #include "kernel_id.h" /*Header file generated by cfg600px*/ #pragma task Task1 /*Refer to note 2*/ void Task1 (VP_INT exinf); /*Refer to note 2*/ void Task1 (VP_INT exinf) { ID tskid = 8; /*Declares and initializes variable*/ T_RTEX pk_rtex; /*Declares data structure*/ STAT texstat; /*Declares variable*/ TEXPTN texptn; /*Declares variable*/ /* ......... */ ref_tex (tskid, &pk_rtex); /*Reference task exception state*/ texstat = pk_rtex.texstat; /*Reference task exception handling state*/ texptn = pk_rtex.texptn; /*Reference pending exception code*/ /* ......... */ } |
Note 1 For details about the task exception state packet, refer to "[Task exception state packet: T_RTEX]".