
CHAPTER 5 SYNCHRONOUS COMMUNICATION MANAGEMENT
User’s Manual U14833EJ2V0UM
55
5.4.3
Receiving data
Data is received from the data queue by issuing one of the service calls rcv_dtq, trcv_dtq, or (i)prcv_dtq.
If there is a data reception request, the kernel checks whether there is unreceived data in the ring buffer being used
by the data queue. If unreceived data exists, the task receives the data at the top of the ring buffer and continues
processing. The kernel then checks the transmission waiting task queue of the data queue, and if there is a task
waiting in this queue, it stores the transmit data of the waiting task in the space in the ring buffer area made available
by the previous data reception processing, at which point the task is released from the waiting state. Accordingly, a
dispatch occurs when the task that was in the waiting state has a higher priority than the task currently running.
If there is no data stored in the ring buffer, the service calls rcv_dtq and trcv_dtq put the task into a data reception
waiting state: until data is received in the case of the former, and until either data is received or a specified time has
elapsed in the case of the latter. The issuance of (i)prcv_dtq results in a service call error, and the error code
E_TMOUT is returned, indicating that polling failed.
Tasks waiting to receive data are registered in the waiting task queue of the data queue. Because multiple tasks
can be waiting in the waiting task queue of the same data queue, a request for data reception sent to a data queue in
whose waiting task queue tasks are already waiting will not result in an error; the task will simply be put in the data
reception waiting state. Tasks can only be registered in the waiting task queue in FIFO order. Waiting tasks are
therefore registered in the queue in the order in which data reception requests were sent, and released in that order
when data is transmitted by a service call such as snd_dtq.
5.4.4
Obtaining data queue information
Data queue information such as the number of data not received can be obtained by using the service calls ref_dtq
and iref_dtq. For details of each service call, refer to
CHAPTER 13
.
5.4.5
Transmitting data
Data is transmitted to the data queue by issuing one of the service calls snd_dtq, (i)psnd_dtq, tsnd_dtq, or
(i)fsnd_dtq.
If there is a data transmission request, the kernel checks the reception waiting task queue of the data queue, and if
there is a task waiting in this queue, it assigns data to the task at the top of the queue and releases that task from the
waiting state. Although it is possible for the task that transmitted the data to continue processing, if the task just
released from the waiting state has a higher priority, then the task currently running is dispatched.
If there are no tasks waiting for reception, the kernel checks the ring buffer of the data queue to see if there is any
free space. If there is free space, the transmit data is copied to the buffer and the task continues processing. If there
is no free space, the service calls snd_dtq and tsnd_dtq put the task into a data transmission waiting state and that
task is registered in the waiting task queue of the data queue until the buffer can be written to. At this time, tasks are
registered in the waiting task queue in the order (FIFO or priority order) specified by the attribute assigned when that
data queue was created. In the case of tsnd_dtq, the task is also released when a specified time has elapsed. If
(i)fsnd_dtq is issued, the oldest data in the ring buffer is discarded and transmission is forcibly carried out. The
issuance of (i)psnd_dtq results in an error if the buffer is not empty, and the error code E_TMOUT is returned,
indicating that polling failed.