What's in a pulse?
Okay, so you receive this message with a receive ID of zero. What does it actually look like?
struct _pulse {
uint16_t type;
uint16_t subtype;
int8_t code;
uint8_t zero [3];
union sigval value;
int32_t scoid;
};
Both the type and subtype members are
zero (a further indication that this is a pulse).
The code and value members are set to
whatever the sender of the pulse determined.
Generally, the code will be an indication of why
the pulse was sent; the value will be a 64-bit
data value associated with the pulse.
These two fields are where the 72 bits
of content
comes from; the other fields aren't user adjustable.
The kernel reserves negative values of code, leaving 128 values for programmers to use as they see fit.
union sigval {
int sival_int;
void *sival_ptr;
long sival_long;
};
#include <sys/neutrino.h>
rcvid = MsgReceive (chid, …);
if (rcvid == 0) { // it's a pulse
// determine the type of pulse
switch (msg.pulse.code) {
case MY_PULSE_TIMER:
// One of your timers went off, do something about it...
break;
case MY_PULSE_HWINT:
// An interrupt service thread sent you a pulse.
// There's a value in the "value" member that you need to
// examine:
val = msg.pulse.value.sival_int;
// Do something about it...
break;
case _PULSE_CODE_UNBLOCK:
// A pulse from the kernel, indicating a client
// unblock was received, do something about it...
break;
// etc...
} else { // it's a regular message
// determine the type of message and handle it
}
This code assumes, of course, that you've set up your msg structure to contain a struct _pulse pulse; member, and that the manifest constants MY_PULSE_TIMER and MY_PULSE_HWINT are defined. The pulse code _PULSE_CODE_UNBLOCK is one of those negative-numbered kernel pulses mentioned above. You can find a complete list of them in <sys/neutrino.h> along with a brief description of the value field.