Description: The start_child_process1() spawns the child process ‘process1’ and also adds one Process Input Handler which accepts every non-photon message as per “https://www.qnx.com/developers/docs/6.3.2/photon/lib_ref/pt/ptappaddinput.html”. The processInputHandler() recieves the pulses from the process1 and process2, but the pid returned from the
When MsgReceive() gets a pulse the return is not a rcvid. From QNX docs:
“On success, both functions return a positive rcvid if they received a message, or EOK if they received a pulse. The only difference between MsgReceive() and MsgReceive_r() is the way they indicate errors:”
That’s why PtGetRcvidPid(rcvid) is always -1.
I can suggest two work arounds.
Stuff the PID in the pulse. There’s just enough room.
Why use a pulse at all? Have the child send a message and then reply immediately. There are legitimate uses for a pulse, but I don’t see one here.
Greetings of the day and thank you for the response.
The system sends pulses from many processes using MsgSendPulse(), where the processInputHandler() need to handle the pulse messages from two different processes.
Here I am trying to filter the pulse messages based on the process ID, so that processInputHandler() can only handles the pulses from the required processes. In many cases, the MsgSendPulse(coid, priority, code, value) inserted some data as “value” argument to pass, that is why I am not able to stuff the PID in the pulse message.
The actual code is below and I am trying to modify as above. Code Snippet Start
static int processInputHandler(void* data, int rcvd, void* message, size_t size) {
struct _pulse* rcvdPulse = (struct _pulse*)message;
if (rcvdPulse->code == PROCESS1_MESSAGE_PULSE1) {
function1();
}
else if (rcvdPulse->code == PROCESS2_MESSAGE_PULSE2) {
function2();
}
return (Pt_CONTINUE);
Currently I am stuffing the PID in the MsgSendPulse(), which are required to handle the processInputHandler(). This way processInputHandler() filter the processes which have valid process ID and handles pulses.
Is there anyway to find out the source of the pulse/message sent which triggers the below input handler?
Currently some unknown source (garbage) is triggering the below input handler and trigger the abnormal behavior on power-up.
The issue is resolved. Thank you for your support.
In the system, Process-3 sends one message with some data to the Process-4 where process 4 has one ‘process input handler’ tied to process4. As the process 4 input handler uses the “Pt_CONTINUE” at the end of the function, OS searches for any other process input handlers tied to process4 or global process input handlers. Then the above mentioned global process input handler receives the message sent by process-3. Coincidentally the data received from the process-3 matches with the “PROCESS1_MESSAGE_PULSE1” value and the “function1();” called.
Solution:
Use Pt_HALT in the process 4 input handler
As you mention filter out messages based on process-ID