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.

<strong>QNX</strong> 4 and <strong>Neutrino</strong><br />

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

Under <strong>Neutrino</strong> this was abstracted into an extension of the POSIX struct<br />

sigevent data structure. Anything that used or returned the struct sigevent<br />

structure can use a signal or a pulse.<br />

In fact, this has been extended further, in that the struct sigevent can even cause<br />

a thread to be created! We talked about this in the Clocks, Timers, and <strong>Getting</strong> a Kick<br />

Every So Often chapter (under “<strong>Getting</strong> notified <strong>with</strong> a thread”).<br />

Device driver model<br />

MIPS, PPC, SH4, and ARM support<br />

Under the previous-previous version of the operating system (the <strong>QNX</strong> 2 family),<br />

writing device drivers was an arcane black art. Under <strong>QNX</strong> 4, it was initially a<br />

mystery, but then eventually some samples appeared. Under <strong>Neutrino</strong>, there are books<br />

and courses on the topic. As it turns out, the <strong>Neutrino</strong> model and the <strong>QNX</strong> 4 model<br />

are, at the highest architectural level, reasonably similar. Whereas <strong>QNX</strong> 4 had<br />

somewhat muddled concepts of what needed to be done as a “connect” function, and<br />

what needed to be done as an “I/O” function, <strong>Neutrino</strong> has a very clear separation.<br />

Also, under <strong>QNX</strong> 4, you (the device driver writer) were responsible for most of the<br />

work — you’d supply the main message handling loop, you’d have to associate<br />

context on each I/O message, and so on. <strong>Neutrino</strong> has simplified this greatly <strong>with</strong> the<br />

resource manager library.<br />

One of the driving changes behind the embeddability differences between <strong>QNX</strong> 4 and<br />

<strong>Neutrino</strong> is the fact that <strong>Neutrino</strong> supports the MIPS, PowerPC, SH4, and ARM<br />

processors. Whereas <strong>QNX</strong> 4 was initially “at home” on an IBM PC <strong>with</strong> a BIOS and<br />

very standard hardware, <strong>Neutrino</strong> is equally at home on multiple processor platforms<br />

<strong>with</strong> or <strong>with</strong>out a BIOS (or ROM monitor), and <strong>with</strong> customized hardware chosen by<br />

the manufacturer (often, it would appear, <strong>with</strong>out regard for the requirements of the<br />

OS). This means that the <strong>Neutrino</strong> kernel had to have provision for callouts, so you<br />

could, for example, decide what kind of interrupt controller hardware you had, and,<br />

<strong>with</strong>out having to buy a source license for the operating system, run on that hardware.<br />

A bunch of other changes you’ll notice when you port <strong>QNX</strong> 4 applications to<br />

<strong>Neutrino</strong>, especially on these different processor platforms, is that they’re fussy about<br />

alignment issues. You can’t access an N-byte object on anything other than an N-byte<br />

multiple of an address. Under the x86 (<strong>with</strong> the alignment flag turned off), you could<br />

access memory willy-nilly. By modifying your code to have properly aligned<br />

structures (for non-x86 processors), you’ll also find that your code runs faster on x86,<br />

because the x86 processor can access aligned data faster.<br />

Another thing that often comes to haunt people is the issue of big-endian versus<br />

little-endian. The x86 processor is a mono-endian processor (meaning it has only one<br />

“endian-ness”), and that’s little-endian. MIPS and PPC, for example, are bi-endian<br />

processors (meaning that the processor can operate in either big-endian or little-endian<br />

mode). Furthermore, these non-x86 processors are “RISC” (Reduced Instruction Set<br />

CPU) machines, meaning that certain operations, such as a simple C language |=<br />

(bitwise set operation) may or may not be performed in an atomic manner. This can<br />

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

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

Saved successfully!

Ooh no, something went wrong!