Hi Folks,
I am using event to communicate between two threads, it seems to me that the priority of the receiving thread get inverted when the event is received even if I initiate the event with SIGEV_PULSE_PRIO_INHERIT flag. I have two threads/processes, the main process created the receiving thread and deliver event to it later on. The priority of both main and receiving thread are 94, the problem is, after receiving a event, the priority of receiving thread downgrade to 11. Here is my related code ( Most of them are just directly from the QNX doc):
/the receiving thread***********/
void receiver_thread()
{
struct _pulse pulse;
/* we need a channel to receive the pulse notification on */
chid = ChannelCreate( 0 );
/* and we need a connection to that channel for the pulse to be
delivered on */
coid = ConnectAttach( 0, 0, chid, _NTO_SIDE_CHANNEL, 0 );
/* find the server */
if ( (srv_coid = name_open( MY_SERV, 0 )) == -1)
{
printf(“failed to find server, errno %d\n”, errno );
exit(1);
}
/* fill in the event structure for a pulse */
SIGEV_PULSE_INIT( &msg.event, coid, SIGEV_PULSE_PRIO_INHERIT,
MY_PULSE_CODE, 0 );
msg.type = MSG_GIVE_PULSE;
/* give the pulse event we initialized above to the server for
later delivery */
MsgSend( srv_coid, &msg, sizeof(msg), NULL, 0 );
/* wait for the pulse from the server */
for( ; ; ) {
rcvid = MsgReceivePulse( chid, &pulse, sizeof( pulse ), NULL );
…/do some process/
}
}
/the end of the receiving thread/
/the main process****/
main()
{
pthread_create(NULL, NULL, (void *)receiver_thread, NULL);
/* attach the name the client will use to find us /
/ our channel will be in the attach structure */
if ( (attach = name_attach( NULL, MY_SERV, 0 )) == NULL)
{
printf(“server:failed to attach name, errno %d\n”, errno );
exit(1);
}
/* wait for the message from the client */
rcvid = MsgReceive( attach->chid, &msg, sizeof( msg ), NULL );
MsgReply(rcvid, 0, NULL, 0);
…/do some work/
/* deliver notification to client that client requested */
MsgDeliverEvent( rcvid, &msg.event );
}
/end of main thread*******/
Any hint?
Thanks!
Yicheng