3.2. Asynchronous data transmission

An asynchronous data transmission involves a mechanism called a queue. In general, a queue is a service which temporarily holds messages destined for a receiving task until that task is ready to process them. The sending task passes messages off to the queue and does not wait for a response from the receiver. The queue guarantees that if it accepts a message then that message will be delivered. Cogent's asynchronous messaging is implemented through a queue administrator, called Cascade QueueServer, or qserve.

Figure 3-2. Asynchronous data transmission

In the example above, when task 1 sends a message to task 2 it does so through the queue administrator. Task 1 transmits the message to the queue administrator, which replies immediately with an acknowledgment that it has held the message for delivery pending a request from task 2. Task 1 can now continue with its other duties without having to wait for task 2 to process the message.

The queue administrator then sends a signal to task 2 telling it that there is a message waiting for it in the queue. A signal is a special operating system mechanism that cannot block on another task and in this case acts like a flag to indicate to task 2 that there is a message waiting. This means that the queue program is never blocked waiting for a reply from a task that it has informed about a message waiting.

Task 2 sends a request for the waiting message and receives the data in a reply from the queue administrator.

It should be noted that the queue administrator never initiates a message transaction, and due to the nature of the send/receive/reply mechanism it will never block while transmitting a reply. Thus a queue administrator in this scenario will always be available to receive messages and the originator of an asynchronous message will never block.

There are a number of disadvantages to using asynchronous message passing. The sender and receiver in an asynchronous transaction must agree upon a queue name in order for the queue administrator to correctly route a message. This requires either hard-coded queue names, command-line arguments, or a queue-aware name server so tasks can discover the destination queue names. The Cascade DataHub uses a queue-aware name server called nserve to provide maximum flexibility in asynchronous connections.

A second concern is that because asynchronous transmission introduces additional message passing overhead into the transmission mechanism, the speed of asynchronous transmission will tend to be slower than that of synchronous data transfer. Perhaps the biggest drawback of the asynchronous transmission method is that there must be a method of dealing with overflows in the queue. If the receiving task fails to collect its messages from the queue administrator, or if it cannot keep up with the rate at which messages are being sent to the queue administrator, then eventually messages will build up and the queue administrator will run out of buffer space. At this point, the queue administrator must refuse further incoming messages until the receiver has cleared some of its pending messages. The sending task must include a contingency plan for undeliverable messages.

A sending task may react in several ways to a full queue situation:

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.