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.

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

message under <strong>QNX</strong> 4 they just did a Receive(). This would block until a message<br />

arrived. The server would then reply <strong>with</strong> the Reply() function.<br />

Under <strong>Neutrino</strong>, message passing is identical (different function names, though).<br />

What’s changed is the mechanism. The client now has to create a connection to a<br />

server before it can do the standard message-passing functions. And the server has to<br />

create a channel before it can do the standard message-passing functions.<br />

Note that the <strong>QNX</strong> 4 Creceive() function, which would do a non-blocking Receive(), is<br />

missing from <strong>Neutrino</strong>. We generally discourage such “polling” functions, especially<br />

when you can start a thread, but if you really insist on performing a non-blocking<br />

MsgReceive(), you should take a look at the Clocks, Timers, and <strong>Getting</strong> a Kick Every<br />

So Often chapter (under “Kernel timeouts”) for more information. For the short story<br />

version, here’s the relevant code sample:<br />

TimerTimeout (CLOCK_REALTIME, _NTO_TIMEOUT_RECEIVE,<br />

NULL, NULL, NULL);<br />

rcvid = MsgReceive (...<br />

Pulses and events<br />

<strong>QNX</strong> 4 provided something called a “proxy.” A proxy is best described as a “canned”<br />

(or “fixed”) message, which could be sent by processes or kernel services (like a timer<br />

or interrupt service routine) to the owner of the proxy. The proxy is non-blocking for<br />

the sender and would arrive just like any other message. The way to identify a proxy<br />

(as opposed to another process actually sending a message) was to either look at the<br />

proxy message contents (not 100% reliable, as a process could send something that<br />

looked like the contents of the proxy) or to examine the process ID associated <strong>with</strong> the<br />

message. If the process ID of the message was the same as the proxy ID, then you<br />

could be assured it was a proxy, because proxy IDs and process IDs were taken from<br />

the same pool of numbers (there’d be no overlap).<br />

<strong>Neutrino</strong> extends the concept of proxies <strong>with</strong> “pulses.” Pulses are still non-blocking<br />

messages, they can still be sent from a thread to another thread, or from a kernel<br />

service (like the timer and ISR mentioned above for proxies) to a thread. The<br />

differences are that while proxies were of fixed-content, <strong>Neutrino</strong> pulses are<br />

fixed-length, but the content can be set by the sender of the pulse at any time. For<br />

example, an ISR could save away a key piece of data into the pulse and then send that<br />

to a thread.<br />

Under <strong>QNX</strong> 4, some services were able to deliver a signal or a proxy, while other<br />

services were able to deliver only one or the other. To complicate matters, the delivery<br />

of these services was usually done in several different ways. For example, to deliver a<br />

signal, you’d have to use the kill() function. To deliver a proxy or signal as a result of a<br />

timer, you’d have to use a negative signal number (to indicate it was a proxy) or a<br />

positive signal number (to indicate it was a signal). Finally, an ISR could deliver only<br />

a proxy.<br />

April 30, 2009 Appendix: A • <strong>QNX</strong> 4 to <strong>Neutrino</strong> 289

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

Saved successfully!

Ooh no, something went wrong!