5.4 Data Queues
Multitask processing requires the inter-task communication function (data transfer function) that reports the processing result of a task to another task. The RI600V4 therefore provides the data queues for transferring the prescribed size of data.
Data queues therefore cannot be created dynamically using a method such as issuing a service call from a processing program.
Static data queue creation means defining of data queues using static API "dataqueue[]" in the system configuration file.
For details about the static API "dataqueue[]", refer to "19.10 Data Queue Information (dataqueue[])".
- snd_dtq (Wait)
This service call processes as follows according to the situation of the data queue specified by the parameter dtqid.
This service call processes as follows according to the situation of the data queue specified by the parameter dtqid.
- There is a task in the reception wait queue.
This service call transfers the data specified by parameter data to the task in the top of the reception wait queue. As a result, the task is unlinked from the reception wait queue and moves from the WAITING state (data reception wait state) to the READY state, or from the WAITING-SUSPENDED state to the SUSPENDED state.
This service call transfers the data specified by parameter data to the task in the top of the reception wait queue. As a result, the task is unlinked from the reception wait queue and moves from the WAITING state (data reception wait state) to the READY state, or from the WAITING-SUSPENDED state to the SUSPENDED state.
- There is no task neither in the reception wait queue and transmission wait queue and there is available space in the data queue.
This service call stores the data specified by parameter data to the data queue.
This service call stores the data specified by parameter data to the data queue.
- There is no task neither in the reception wait queue and transmission wait queue and there is no available space in the data queue, or there is a task in the transmission wait queue.
This service call queues the invoking task to the transmission wait queue of the target data queue and moves it from the RUNNING state to the WAITING state (data transmission wait state).
The sending WAITING state for a data queue is cancelled in the following cases.
This service call queues the invoking task to the transmission wait queue of the target data queue and moves it from the RUNNING state to the WAITING state (data transmission wait state).
The sending WAITING state for a data queue is cancelled in the following cases.
#include "kernel.h" /*Standard header file definition*/ #include "kernel_id.h" /*Header file generated by cfg600*/ void task (VP_INT exinf) { ER ercd; /*Declares variable*/ ID dtqid = 1; /*Declares and initializes variable*/ VP_INT data = 123; /*Declares and initializes variable*/ /* ......... */ ercd = snd_dtq (dtqid, data); /*Send to data queue*/ if (ercd == E_OK) { /* ......... */ /*Normal termination processing*/ } else if (ercd == E_RLWAI) { /* ......... */ /*Forced termination processing*/ } /* ......... */ } |
Note 2 Invoking tasks are queued to the transmission wait queue of the target data queue in the order defined during configuration (FIFO order or current priority order).
- psnd_dtq, ipsnd_dtq (Polling)
These service calls process as follows according to the situation of the data queue specified by the parameter dtqid.
These service calls process as follows according to the situation of the data queue specified by the parameter dtqid.
- There is a task in the reception wait queue.
These service calls transfer the data specified by parameter data to the task in the top of the reception wait queue. As a result, the task is unlinked from the reception wait queue and moves from the WAITING state (data reception wait state) to the READY state, or from the WAITING-SUSPENDED state to the SUSPENDED state.
These service calls transfer the data specified by parameter data to the task in the top of the reception wait queue. As a result, the task is unlinked from the reception wait queue and moves from the WAITING state (data reception wait state) to the READY state, or from the WAITING-SUSPENDED state to the SUSPENDED state.
- There is no task neither in the reception wait queue and transmission wait queue and there is available space in the data queue.
These service calls store the data specified by parameter data to the data queue.
These service calls store the data specified by parameter data to the data queue.
- There is no task neither in the reception wait queue and transmission wait queue and there is no available space in the data queue, or there is a task in the transmission wait queue.
These service calls return "E_TMOUT".
These service calls return "E_TMOUT".
#include "kernel.h" /*Standard header file definition*/ #include "kernel_id.h" /*Header file generated by cfg600*/ void task (VP_INT exinf) { ER ercd; /*Declares variable*/ ID dtqid = 1; /*Declares and initializes variable*/ VP_INT data = 123; /*Declares and initializes variable*/ /* ......... */ ercd = psnd_dtq (dtqid, data); /*Send to data queue* if (ercd == E_OK) { /* ......... */ /*Polling success processing*/ } else if (ercd == E_TMOUT) { /* ......... */ /*Polling failure processing*/ } /* ......... */ } |
- tsnd_dtq (Wait with time-out)
This service call processes as follows according to the situation of the data queue specified by the parameter dtqid.
This service call processes as follows according to the situation of the data queue specified by the parameter dtqid.
- There is a task in the reception wait queue.
This service call transfers the data specified by parameter data to the task in the top of the reception wait queue. As a result, the task is unlinked from the reception wait queue and moves from the WAITING state (data reception wait state) to the READY state, or from the WAITING-SUSPENDED state to the SUSPENDED state.
This service call transfers the data specified by parameter data to the task in the top of the reception wait queue. As a result, the task is unlinked from the reception wait queue and moves from the WAITING state (data reception wait state) to the READY state, or from the WAITING-SUSPENDED state to the SUSPENDED state.
- There is no task neither in the reception wait queue and transmission wait queue and there is available space in the data queue.
This service call stores the data specified by parameter data to the data queue.
This service call stores the data specified by parameter data to the data queue.
- There is no task neither in the reception wait queue and transmission wait queue and there is no available space in the data queue, or there is a task in the transmission wait queue.
This service call queues the invoking task to the transmission wait queue of the target data queue and moves it from the RUNNING state to the WAITING state with time (data transmission wait state).
The sending WAITING state for a data queue is cancelled in the following cases.
This service call queues the invoking task to the transmission wait queue of the target data queue and moves it from the RUNNING state to the WAITING state with time (data transmission wait state).
The sending WAITING state for a data queue is cancelled in the following cases.
#include "kernel.h" /*Standard header file definition*/ #include "kernel_id.h" /*Header file generated by cfg600*/ void task (VP_INT exinf) { ER ercd; /*Declares variable*/ ID dtqid = 1; /*Declares and initializes variable*/ VP_INT data = 123; /*Declares and initializes variable*/ TMO tmout = 3600; /*Declares and initializes variable*/ /* ......... */ /*Send to data queue*/ ercd = tsnd_dtq (dtqid, data, tmout); if (ercd == E_OK) { /* ......... */ /*Normal termination processing*/ } else if (ercd == E_RLWAI) { /* ......... */ /*Forced termination processing*/ } else if (ercd == E_TMOUT) { /* ......... */ /*Time-out processing*/ } /* ......... */ } |
Note 2 Invoking tasks are queued to the transmission wait queue of the target data queue in the order defined during configuration (FIFO order or current priority order).
Note 3 TMO_FEVR is specified for wait time tmout, processing equivalent to snd_dtq will be executed. When TMO_POL is specified, processing equivalent to psnd_dtq will be executed.
- fsnd_dtq, ifsnd_dtq
This service call processes as follows according to the situation of the data queue specified by the parameter dtqid.
This service call processes as follows according to the situation of the data queue specified by the parameter dtqid.
- There is a task in the reception wait queue.
This service call transfers the data specified by parameter data to the task in the top of the reception wait queue. As a result, the task is unlinked from the reception wait queue and moves from the WAITING state (data reception wait state) to the READY state, or from the WAITING-SUSPENDED state to the SUSPENDED state.
This service call transfers the data specified by parameter data to the task in the top of the reception wait queue. As a result, the task is unlinked from the reception wait queue and moves from the WAITING state (data reception wait state) to the READY state, or from the WAITING-SUSPENDED state to the SUSPENDED state.
- There is no task neither in the reception wait queue and transmission wait queue.
This service call stores the data specified by parameter data to the data queue.
If there is no available space in the data queue, this service call deletes the oldest data in the data queue before storing the data specified by data to the data queue.
This service call stores the data specified by parameter data to the data queue.
If there is no available space in the data queue, this service call deletes the oldest data in the data queue before storing the data specified by data to the data queue.
#include "kernel.h" /*Standard header file definition*/ #include "kernel_id.h" /*Header file generated by cfg600*/ void task (VP_INT exinf) { ID dtqid = 1; /*Declares and initializes variable*/ VP_INT data = 123; /*Declares and initializes variable*/ /* ......... */ fsnd_dtq (dtqid, data); /*Forced send to data queue*/ /* ......... */ } |
A data is received (waiting forever, polling, or with time-out) by issuing the following service call from the processing program.
- rcv_dtq (Wait)
This service call processes as follows according to the situation of the data queue specified by the parameter dtqid.
This service call processes as follows according to the situation of the data queue specified by the parameter dtqid.
- There is a data in the data queue.
This service call takes out the oldest data from the data queue and stores the data to the area specified by p_data.
When there is a task in the transmission wait queue, this service call stores the data sent by the task in the top of the transmission wait queue and moves it from the WAITING state (data transmission wait state) to the READY state.
This service call takes out the oldest data from the data queue and stores the data to the area specified by p_data.
When there is a task in the transmission wait queue, this service call stores the data sent by the task in the top of the transmission wait queue and moves it from the WAITING state (data transmission wait state) to the READY state.
- There is no data in the data queue and there is a task in the transmission wait queue.
This service call stores the data specified by the task in the top of the transmission wait queue to the area specified by p_data. As a result, the task is unlinked from the transmission wait queue and moves from the WAITING state (data transmission wait state) to the READY state, or from the WAITING-SUSPENDED state to the SUSPENDED state.
Note, this situation is caused only when the capacity of the data queue is 0.
This service call stores the data specified by the task in the top of the transmission wait queue to the area specified by p_data. As a result, the task is unlinked from the transmission wait queue and moves from the WAITING state (data transmission wait state) to the READY state, or from the WAITING-SUSPENDED state to the SUSPENDED state.
Note, this situation is caused only when the capacity of the data queue is 0.
- There is no data in the data queue and there is no task in the transmission wait queue.
This service call queues the invoking task to the reception wait queue of the target data queue and moves it from the RUNNING state to the WAITING state (data reception wait state).
The receiving WAITING state for a data queue is cancelled in the following cases.
This service call queues the invoking task to the reception wait queue of the target data queue and moves it from the RUNNING state to the WAITING state (data reception wait state).
The receiving WAITING state for a data queue is cancelled in the following cases.
#include "kernel.h" /*Standard header file definition*/ #include "kernel_id.h" /*Header file generated by cfg600*/ void task (VP_INT exinf) { ER ercd; /*Declares variable*/ ID dtqid = 1; /*Declares and initializes variable*/ VP_INT p_data; /*Declares variable*/ /* ......... */ /*Receive from data queue*/ ercd = rcv_dtq (dtqid, &p_data); if (ercd == E_OK) { /* ......... */ /*Normal termination processing*/ } else if (ercd == E_RLWAI) { /* ......... */ /*Forced termination processing*/ } /* ......... */ } |
Note Invoking tasks are queued to the reception wait queue of the target data queue in the order of the data reception request.
- prcv_dtq, iprcv_dtq (Polling)
These service calls process as follows according to the situation of the data queue specified by the parameter dtqid.
These service calls process as follows according to the situation of the data queue specified by the parameter dtqid.
- There is a data in the data queue.
This service call takes out the oldest data from the data queue and stores the data to the area specified by p_data.
When there is a task in the transmission wait queue, this service call stores the data sent by the task in the top of the transmission wait queue and moves it from the WAITING state (data transmission wait state) to the READY state.
This service call takes out the oldest data from the data queue and stores the data to the area specified by p_data.
When there is a task in the transmission wait queue, this service call stores the data sent by the task in the top of the transmission wait queue and moves it from the WAITING state (data transmission wait state) to the READY state.
- There is no data in the data queue and there is a task in the transmission wait queue.
These service calls store the data specified by the task in the top of the transmission wait queue to the area specified by p_data. As a result, the task is unlinked from the transmission wait queue and moves from the WAITING state (data transmission wait state) to the READY state, or from the WAITING-SUSPENDED state to the SUSPENDED state.
Note, this situation is caused only when the capacity of the data queue is 0.
These service calls store the data specified by the task in the top of the transmission wait queue to the area specified by p_data. As a result, the task is unlinked from the transmission wait queue and moves from the WAITING state (data transmission wait state) to the READY state, or from the WAITING-SUSPENDED state to the SUSPENDED state.
Note, this situation is caused only when the capacity of the data queue is 0.
- There is no data in the data queue and there is no task in the transmission wait queue.
These service calls return "E_TMOUT".
These service calls return "E_TMOUT".
#include "kernel.h" /*Standard header file definition*/ #include "kernel_id.h" /*Header file generated by cfg600*/ void task (VP_INT exinf) { ER ercd; /*Declares variable*/ ID dtqid = 1; /*Declares and initializes variable*/ VP_INT p_data; /*Declares variable*/ /* ......... */ /*Receive from data queue*/ ercd = prcv_dtq (dtqid, &p_data); if (ercd == E_OK) { /* ......... */ /*Polling success processing*/ } else if (ercd == E_TMOUT) { /* ......... */ /*Polling failure processing*/ } /* ......... */ } |
- trcv_dtq (Wait with time-out)
This service call processes as follows according to the situation of the data queue specified by the parameter dtqid.
This service call processes as follows according to the situation of the data queue specified by the parameter dtqid.
- There is a data in the data queue.
This service call takes out the oldest data from the data queue and stores the data to the area specified by p_data.
When there is a task in the transmission wait queue, this service call stores the data sent by the task in the top of the transmission wait queue and moves it from the WAITING state (data transmission wait state) to the READY state.
This service call takes out the oldest data from the data queue and stores the data to the area specified by p_data.
When there is a task in the transmission wait queue, this service call stores the data sent by the task in the top of the transmission wait queue and moves it from the WAITING state (data transmission wait state) to the READY state.
- There is no data in the data queue and there is a task in the transmission wait queue.
This service call stores the data specified by the task in the top of the transmission wait queue to the area specified by p_data. As a result, the task is unlinked from the transmission wait queue and moves from the WAITING state (data transmission wait state) to the READY state, or from the WAITING-SUSPENDED state to the SUSPENDED state.
Note, this situation is caused only when the capacity of the data queue is 0.
This service call stores the data specified by the task in the top of the transmission wait queue to the area specified by p_data. As a result, the task is unlinked from the transmission wait queue and moves from the WAITING state (data transmission wait state) to the READY state, or from the WAITING-SUSPENDED state to the SUSPENDED state.
Note, this situation is caused only when the capacity of the data queue is 0.
- There is no data in the data queue and there is no task in the transmission wait queue.
This service call queues the invoking task to the reception wait queue of the target data queue and moves it from the RUNNING state to the WAITING state with time (data reception wait state).
The receiving WAITING state for a data queue is cancelled in the following cases.
This service call queues the invoking task to the reception wait queue of the target data queue and moves it from the RUNNING state to the WAITING state with time (data reception wait state).
The receiving WAITING state for a data queue is cancelled in the following cases.
#include "kernel.h" /*Standard header file definition*/ #include "kernel_id.h" /*Header file generated by cfg600*/ void task (VP_INT exinf) { ER ercd; /*Declares variable*/ ID dtqid = 1; /*Declares and initializes variable*/ VP_INT p_data; /*Declares variable*/ TMO tmout = 3600; /*Declares and initializes variable*/ /* ......... */ /*Receive from data queue*/ ercd = trcv_dtq (dtqid, &p_data, tmout); if (ercd == E_OK) { /* ......... */ /*Normal termination processing*/ } else if (ercd == E_RLWAI) { /* ......... */ /*Forced termination processing*/ } else if (ercd == E_TMOUT) { /* ......... */ /*Time-out processing*/ } /* ......... */ } |
Note 1 Invoking tasks are queued to the reception wait queue of the target data queue in the order of the data reception request.
Note 2 TMO_FEVR is specified for wait time tmout, processing equivalent to rcv_dtq will be executed. When TMO_POL is specified, processing equivalent to prcv_dtq will be executed.
A data queue status is referenced by issuing the following service call from the processing program.
- ref_dtq, iref_dtq
These service calls store the detailed information of the data queue (existence of waiting tasks, number of data elements in the data queue, etc.) specified by parameter dtqid into the area specified by parameter pk_rdtq.
The following describes an example for coding these service calls.
These service calls store the detailed information of the data queue (existence of waiting tasks, number of data elements in the data queue, etc.) specified by parameter dtqid into the area specified by parameter pk_rdtq.
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 cfg600*/ void task (VP_INT exinf) { ID dtqid = 1; /*Declares and initializes variable*/ T_RDTQ pk_rdtq; /*Declares data structure*/ ID stskid; /*Declares variable*/ ID rtskid; /*Declares variable*/ UINT sdtqcnt; /*Declares variable*/ /* ......... */ ref_dtq (dtqid, &pk_rdtq); /*Reference data queue state*/ stskid = pk_rdtq.stskid; /*Acquires existence of tasks waiting for */ /*data transmission*/ rtskid = pk_rdtq.rtskid; /*Acquires existence of tasks waiting for */ /*data reception*/ sdtqcnt = pk_rdtq.sdtqcnt; /*Reference the number of data elements in */ /*data queue*/ /* ......... */ } |