Belinda <email@example.com> wrote:
I have trouble with concepts of pulses.
In the manuals of qnx, it is said that pulse is asynchronization service
provided by QNX operating sytem. Furthermore, if multiple pulses are sent to
a channel without a thread waiting to receive them, the pulses are queued in
priority order. So where did pulses are buffered?
The kernel allocates memory and queues them in kernel space, the
queue is associated with the receiving channel.
Such that, if one thread sends pulses continously to another thread,
however, the receiving thread is blocked due to some reasons. As a result,
is this pulse missed or is waiting on the channel till the receiver thread
is released and ready to receive it?
The pulse are not lost.
In general, the only time a pulse is lost is if you do a MsgReceive*()
and your received buffer is less than the size of a struct _pulse, in this
case, the pulse is discarded, and your MsgReceive*() will return -1.
If the receiving thread can accept
different kinds of pulses, so are these pulses buffered in the same queue or
In general, if they are all sent to the same channel, they will be in the
same queue. (Most receiving processes only use one channel. But, you get
a queue per channel.)
And what is size of pulse queue if they are buffered in
There is no arbitrary limit – entries are allocated on demand. Some
“compression” of identical pulses is done, if this will not change the
order of delivery. Degenerate cases can cause problems for QNX.
Moreover, between message-passing and pulses, which way is more safe and
fast for tasks communication?
Depends on what you are trying to do. Pulses and messages are intended
for different things. Pulse are generally used for notification –
“something happened”. Messages are used for moving data and getting
work done – “please give me data”, “please do something with data”,
or “please do something with this data and give me the results”.
Both are safe, both are moderately fast. A pulse is faster than a
message if you just want to notify. But, if you need to move 200
bytes from one process to another, a message pass will be faster
than using 50 pules.
If you want to move really large amounts of data around, it may
be worth looking at shared memory. Quite possibly using message
passing on top, for the inherent synchronisation.
QNX Training Services
Please followup in this newsgroup if you have further questions.