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.

Priority inheritance<br />

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

Magenta’s ND is 7<br />

From magenta’s point of view, we’re ND 4<br />

This says that on magenta, the node descriptor “4” refers to our node. (Notice the use<br />

of the special constant ND_LOCAL_NODE, which is really zero, to indicate “this<br />

node.”)<br />

Now, recall that we said (in “Who sent the message?”) that the struct _msg_info<br />

contains, among other things, two node descriptors:<br />

struct _msg_info<br />

{<br />

int nd;<br />

int srcnd;<br />

...<br />

};<br />

We stated in the description for those two fields that:<br />

• nd is the receiving node’s node descriptor for the transmitting node<br />

• srcnd is the transmitting node’s node descriptor for the receiving node<br />

So, for our example above, where wintermute is the local node and magenta is the<br />

remote node, when magenta sends a message to us (wintermute), we’d expect that:<br />

• nd would contain 7<br />

Priority inheritance<br />

• srcnd would contain 4.<br />

One of the interesting issues in a realtime operating system is a phenomenon known as<br />

priority inversion.<br />

Priority inversion manifests itself as, for example, a low-priority thread consuming all<br />

available CPU time, even though a higher-priority thread is ready to run.<br />

Now you’re probably thinking, “Wait a minute! You said that a higher-priority thread<br />

will always preempt a lower-priority thread! How can this be?”<br />

This is true — a higher-priority thread will always preempt a lower-priority thread.<br />

But something interesting can happen. Let’s look at a scenario where we have three<br />

threads (in three different processes, just to keep things simple), “L” is our low-priority<br />

thread, “H” is our high-priority thread, and “S” is a server. This diagram shows the<br />

three threads and their priorities:<br />

130 Chapter 2 • Message Passing April 30, 2009

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

Saved successfully!

Ooh no, something went wrong!