
CHAPTER 5 SYNCHRONOUS COMMUNICATION MANAGEMENT
User’s Manual U14833EJ2V0UM
54
5.4
Data Queues
In a multitasking environment, when multiple tasks operate together to perform a specified processing, an intertask
communication function is required to inform other tasks of the execution results of a certain task. In the RX4000,
data queues and mailboxes are provided as a means of realizing this function. For a data queue, transmit data is fixed
to 4 bytes and there is a limit to the total amount of data that can be stored. For a mailbox on the other hand, data of
any format can be transmitted, and there is no limit to the total amount of storable data. Users can therefore select
and use whichever of these has the features that accord with their system configuration. This section describes data
queues, which consist of a ring buffer in which the data to be communicated is stored and a waiting task queue in
which waiting tasks are registered. Data queues not only enable communication between tasks, but also make it
possible to have tasks wait in response to data.
5.4.1
Creating data queues
Data queues can be created either by issuing the service call (a)cre_dtq, or by specifying the static API CRE_DTQ,
which performs equivalent processing to (a)cre_dtq when the system is initialized.
When (a)cre_dtq is issued, firstly the area of the ring buffer to be used by the data queue is secured from the user
pool. After that, the attribute, buffer address, and buffer size (etc.) are stored in the block corresponding to the ID
number that specifies the data queue control block area, and that control block is then initialized.
The data queue ID number consists of a unique number of a value 1 or higher. The maximum value that can be
specified is the one defined in the system information table, up to a maximum of 0x7fff numbers.
Note that data queues without buffers can also be created.
5.4.2
Deleting data queues
A data queue is deleted by issuing the del_dtq service call. When del_dtq is issued, the kernel returns the area of
the ring buffer being used by the specified data queue to the user pool and then invalidates the control block and puts
the target data queue in the non-existent state.
Even if a task exists that has transmit/receive data for the deleted data queue, that data queue will still be deleted.
In this case, all the waiting tasks are released from the waiting state and the error code E_DLT indicating that the data
queue has been deleted is returned as the return value of the service call.
After a data queue is deleted, a data queue with the same ID number as the deleted data queue can be newly
created.