Find out if a message channel has a waiting message.

Hi All,

Is there a way to find out if a QNX message channel has any queued messages?

The functionality I’m looking for is this: after creating a channel with ChannelCreate(), I don’t want MsgReceivePulse() to block. Instead I want MsgReceivePulse() to return a pulse if there’s one waiting in the channel, or return an error if the channel is empty. This behavoir is very much like sem_trywait().

If QNX has a function to test the emptyness of a message channel, then I can use that to write an implementation of MsgTryReceivePulse().

Yes, before MsgReceivePulse set timeout to 0 via TimerTimeout(). … meout.html

Thanks for the info.

I implemented a POSIX semaphore replacement with message pulse, and got a substantial performance boost. My semaphore operations now take approximately 40% less time. Not surprising results considering QNX is optimized for message passing.

40% less time then what?

Funny but I wouldn’t though of using pulses to implement semaphore like operation since they are asynchronous in nature.

Those dang semaphores just keep blocking. If you make them non-blocking it really speeds things up :wink: