Proxies for their IDs

If you're comparing the received process ID against the list of proxies that you're expecting, then you'll usually ignore the actual contents of the proxy. After all, since the proxy message couldn't be changed once you've created it, what additional information would you have gained by looking at the message once you knew it was one of your proxies? You could argue that as a convenience you'd place a message into the proxy that you could then look at with your standard message decoding. If that's the case, see below, Proxies for their contents.

Therefore, under QNX 4, you'd see code like:

pid = Receive (0, &msg, sizeof (msg));
if (pid == proxyPidTimer) {
    // we got hit with the timer, do something
} else if (pid == proxyPidISR) {
    // our ISR went off, do something
} else {
    // not one of our proxies, must have been a regular
    // message for a client.  Do something.
}

Under QNX Neutrino, you'd replace this code with the following:

rcvid = MsgReceive (chid, &msg, sizeof (msg), NULL);
if (rcvid == 0) {   // 0 indicates it was a pulse
    switch (msg.pulse.code) {
    case    MyCodeTimer:
        // we got hit with the timer, do something
        break;
    case    MyCodeISR:
        // our ISR went off, do something
        break;
    default:
        // unknown pulse code, log it, whatever.
        break;
    }
} else {
    // rcvid is not zero, therefore not a pulse but a
    // regular message from a client.  Do something.
}

Note that this example would be used if you're handling all messages yourself. Since we recommend using the resource manager library, your code would really look more like this:

int
main (int argc, char **argv)
{
    …
    // do the usual initializations

    pulse_attach (dpp, 0, MyCodeTimer, my_timer_pulse_handler,
                  NULL);
    pulse_attach (dpp, 0, MyCodeISR, my_isr_pulse_handler, 
                  NULL);
    
    …
}

This time, we're telling the resource manager library to put the two checks that we showed in the previous example into its receive loop and call our two handling functions (my_timer_pulse_handler() and my_isr_pulse_handler()) whenever those codes show up. Much simpler.