mChannelId: is the channel created or passed your function (created via ChannelCreate() call). This is where the pulse will be delivered when the timer expires.
userId: is a unique identifier for your timer (1-5 in your case) so that you can identify which timer expires.
Then in your message handling code that receives messages/timer pulses you will have something like:
struct Message
{
// This structure contains timer events
struct _pulse timerPulse;
// This structure contains event message data (our data in a message)
Event data;
};
Message msg;
int mRecvId;
if ((mRecvId = MsgReceive_r(mChannelId, &msg, sizeof(Message), NULL)) < 0)
{
printf ("error");
}
else
{
// Determine if we received a message or timer pulse
if (mRecvId == 0)
{
switch (msg.timerPulse.code)
{
case _PULSE_CODE_DISCONNECT:
// Remote side disconnecting via name_close() from a
// name_open (this only occurs for a server process)
ConnectDetach_r(msg.timerPulse.scoid);
break;
case _PULSE_CODE_UNBLOCK:
// Sender hit by a signal so release them to process it
Message emptyReply;
reply(emptyReply);
break;
case _PULSE_CODE_THREADDEATH:
case _PULSE_CODE_COIDDEATH:
// Remote side died/exited!
break;
default:
// Timer pulse received
processTimeout(msg.timerPulse.value.sival_int);
break;
}
}
else
{
// Actual message data.
}
}
Where:
msg.timerPulse.value.sival_int is your unique timer id that was userId above.
Note that I cut out all code processing actual message data and omitted some error checks to simplify the code.