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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Message passing over a network<br />

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

srcmsglen<br />

(Qnet likes to transfer 8 KB).<br />

indicates how much data the client wanted to transfer (determined by<br />

the client).<br />

Some notes on NDs<br />

So, if the client wanted to transfer 1 megabyte of data over the network, the server’s<br />

MsgReceive() would unblock and msglen would be set to 8192 (indicating that 8192<br />

bytes were available in the buffer), while srcmsglen would be set to 1048576<br />

(indicating that the client tried to send 1 megabyte).<br />

The server then uses MsgRead() to get the rest of the data from the client’s address<br />

space.<br />

The other “funny” thing that we haven’t yet talked about when it comes to message<br />

passing is this whole business of a “node descriptor” or just “ND” for short.<br />

Recall that we used symbolic node names, like /net/wintermute in our examples.<br />

Under <strong>QNX</strong> 4 (the previous version of the OS before <strong>Neutrino</strong>), native networking<br />

was based on the concept of a node ID, a small integer that was unique on the network.<br />

Thus, we’d talk about “node 61,” or “node 1,” and this was reflected in the function<br />

calls.<br />

Under <strong>Neutrino</strong>, all nodes are internally referred to by a 32-bit quantity, but it’s not<br />

network unique! What I mean by that is that wintermute might think of spud as<br />

node descriptor number “7,” while spud might think of magenta as node descriptor<br />

number “7” as well. Let me expand that to give you a better picture. This table shows<br />

some sample node descriptors that might be used by three nodes, wintermute, spud,<br />

and foobar:<br />

Node wintermute spud foobar<br />

wintermute 0 7 4<br />

spud 4 0 6<br />

foobar 5 7 0<br />

Notice how each node’s node descriptor for itself is zero. Also notice how<br />

wintermute’s node descriptor for spud is “7,” as is foobar’s node descriptor for<br />

spud. But wintermute’s node descriptor for foobar is “4” while spud’s node<br />

descriptor for foobar is “6.” As I said, they’re not unique across the network,<br />

although they are unique on each node. You can effectively think of them as file<br />

descriptors — two processes might have the same file descriptor if they access the<br />

same file, but they might not; it just depends on who opened which file when.<br />

Fortunately, you don’t have to worry about node descriptors, for a number of reasons:<br />

1 Most of the off-node message passing you’ll typically be doing will be through<br />

higher-level function calls (such as open(), as shown in the example above).<br />

128 Chapter 2 • Message Passing April 30, 2009

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

Saved successfully!

Ooh no, something went wrong!