26.02.2014 Views

Getting Started with QNX Neutrino - QNX Software Systems

Getting Started with QNX Neutrino - QNX Software Systems

Getting Started with QNX Neutrino - QNX Software Systems

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Using message passing<br />

© 2009, <strong>QNX</strong> <strong>Software</strong> <strong>Systems</strong> GmbH & Co. KG.<br />

Let’s examine the arguments:<br />

coid<br />

sparts and rparts<br />

siov and riov<br />

The connection ID that we’re sending to, just as <strong>with</strong><br />

MsgSend().<br />

The number of send and receive parts specified by the iov_t<br />

parameters. In our example, we set sparts to 2 indicating that<br />

we’re sending a 2-part message, and rparts to 1 indicating that<br />

we’re receiving a 1-part reply.<br />

The iov_t arrays indicate the address and length pairs that we<br />

wish to send. In the above example, we set up the 2 part siov to<br />

point to the header and the client data, and the 1 part riov to<br />

point to just the header.<br />

This is how the kernel views the data:<br />

Header<br />

Header<br />

Header and<br />

data chunk<br />

Data chunk<br />

Data chunk<br />

Client's address space<br />

Kernel copying data<br />

Driver's address space<br />

How the kernel sees a multipart message.<br />

The kernel just copies the data seamlessly from each part of the IOV in the client’s<br />

space into the server’s space (and back, for the reply). Effectively, the kernel is<br />

performing a gather-scatter operation.<br />

A few points to keep in mind:<br />

• The number of parts is “limited” to 512 KB; however, our example of 2 is typical.<br />

• The kernel simply copies the data specified in one IOV from one address space into<br />

another.<br />

• The source and the target IOVs don’t have to be identical.<br />

Why is the last point so important? To answer that, let’s take a look at the big picture.<br />

On the client side, let’s say we issued:<br />

write (fd, buf, 12000);<br />

which generated a two-part IOV of:<br />

• header (12 bytes)<br />

• data (12000 bytes)<br />

110 Chapter 2 • Message Passing April 30, 2009

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!