In this chapter, we'll look at the most distinctive feature of QNX Neutrino,
message passing.
Message passing lies at the heart of the operating system's
microkernel architecture, giving the OS its modularity.
A small microkernel and message passing
One of the principal advantages of QNX Neutrino is that it's scalable. By "scalable" I mean that it can be tailored to work on tiny embedded boxes with tight memory constraints, right up to large networks of multiprocessor SMP boxes with almost unlimited memory.
Message passing and client/server
Imagine an application reading data from the filesystem. In QNX lingo, the application is a client requesting the data from a server.
Network-distributed message passing
Suppose we want to change our example above to talk to a different node on the network. You might think that we'll have to invoke special function calls to "get networked." Here's the network version's code:
What it means for you
Message passing is elegant and network-distributed. So what? What does it buy you, the programmer?
Multiple threads
Although the client/server model is easy to understand, and the most commonly used, there are two other variations on the theme. The first is the use of multiple threads (the topic of this section), and the second is a model called server/subserver that's sometimes useful for general design, but really shines in network-distributed designs. The combination of the two can be extremely powerful, especially on a network of SMP boxes!
Using message passing
Now that we've seen the basic concepts involved in message passing, and learned that even common everyday things like the C library use it, let's take a look at some of the details.
Pulses
All the messaging we've talked about so far blocks the client. It's nap time for the client as soon as it calls MsgSend(). The client sleeps until the server gets around to replying.
Message passing over a network
To keep things clear, I've avoided talking about how you'd use message passing over a network, even though this is a crucial part of QNX Neutrino's flexibility!
Priority inheritance
One of the interesting issues in a realtime operating system is a phenomenon known as priority inversion.