Msg passing approaches under Qnet

I have developed an adhoc network among several 6.3.2 machines. Currently, one need to communicate with one another.

e.g, one process on machine A has generated some data from the data acquisition board and do some processing with it,
then the processed data need to be transferred to another process in machine B.

As i know, one way is that A put the processed data in a file, then B can access the data across the Qnet, much like
write and open a file on the wireless network. But it seems to me not very efficient, any other better ways of
transferring data? Thank u.

This can be done with message passing in two ways.

  1. machine A sends a message to machine B with the data. machine B replies when it gets it.
  2. machine B sends a message to machine A saying it is ready to receive data. When machine A has data, it returns it to B in a Reply.

It may be the case that you want to use 1) but A cannot wait for a network send and reply. In that case Thread 1 in machine A can put the data in a buffer, and wake up Thread 2 which sends the message.

It might also be the case that you want to use 2) and A can wait for B to reply, but it cannot tolerate waiting for B to reply a previous message. In this case, you can either use a thread pool in B, or you could do it with just two threads in B, one receives data and puts it in a buffer while thread the second processes the data.

The latter two examples require synchronization with mutexes and maybe condvars.

These methods only breaks down if 1) The rate that A receives data is slower that the rate at which B processes it, and 2) The available memory is not large enough to buffer the data before memory runs out. For this to happen you would probably need a fairly continuous stream of data.