RTP equivalent of select_receive

I’m sure this has come up before, but I could not find anything in the
knowledge base, so I’ll ask again…

What is the appropriate mechanism for doing a MsgReceive() or a
select() that will inform me whenever any of the following occurs:

  1. a MsgSend-style message arrives
  2. a pulse arrives
  3. a fd has input waiting on it
  4. a fd is available for output

In short, is there an approximate equivalent to select_receive() in
Neutrino? If the answer involves ionotify(), do you have a simple
code example that would help to clarify the usage?

Thanks,
Andrew

Andrew Thomas <Andrew@cogent.ca> wrote:

I’m sure this has come up before, but I could not find anything in the
knowledge base, so I’ll ask again…

What is the appropriate mechanism for doing a MsgReceive() or a
select() that will inform me whenever any of the following occurs:

  1. a MsgSend-style message arrives
  2. a pulse arrives
  3. a fd has input waiting on it
  4. a fd is available for output

In short, is there an approximate equivalent to select_receive() in
Neutrino?

There are two ways of doing this.

Your process that is receiving messages could be a resource manager,
and use the select_attach() call to attach handlers to file descriptors.
You would use pulse_attach() to handle incoming pulses. For messages,
you could use message_attach(), or there are other ways as well.

Or, as you guessed, you can use ionotify() to request notification.
Unfortunately, I don’t have an example of this handy to give you.

-David

QNX Training Services
dagibbs@qnx.com

Previously, David Gibbs wrote in qdn.public.qnxrtp.os:

Andrew Thomas <> Andrew@cogent.ca> > wrote:
I’m sure this has come up before, but I could not find anything in the
knowledge base, so I’ll ask again…

What is the appropriate mechanism for doing a MsgReceive() or a
select() that will inform me whenever any of the following occurs:

  1. a MsgSend-style message arrives
  2. a pulse arrives
  3. a fd has input waiting on it
  4. a fd is available for output

In short, is there an approximate equivalent to select_receive() in
Neutrino?

There are two ways of doing this.

Your process that is receiving messages could be a resource manager,
and use the select_attach() call to attach handlers to file descriptors.
You would use pulse_attach() to handle incoming pulses. For messages,
you could use message_attach(), or there are other ways as well.

Or, as you guessed, you can use ionotify() to request notification.
Unfortunately, I don’t have an example of this handy to give you.

Thanks for the response, David. Unfortunately this is not a resource
manager. I am working on a multi-platform IPC library so it has to
run in user program code.

If you run across any usage examples for ionotify(), please think of
me.

Thanks,
Andrew

Andrew Thomas wrote:

Previously, David Gibbs wrote in qdn.public.qnxrtp.os:
Andrew Thomas <> Andrew@cogent.ca> > wrote:
I’m sure this has come up before, but I could not find anything in the
knowledge base, so I’ll ask again…

What is the appropriate mechanism for doing a MsgReceive() or a
select() that will inform me whenever any of the following occurs:

  1. a MsgSend-style message arrives
  2. a pulse arrives
  3. a fd has input waiting on it
  4. a fd is available for output

In short, is there an approximate equivalent to select_receive() in
Neutrino?

There are two ways of doing this.

Your process that is receiving messages could be a resource manager,
and use the select_attach() call to attach handlers to file descriptors.
You would use pulse_attach() to handle incoming pulses. For messages,
you could use message_attach(), or there are other ways as well.

Or, as you guessed, you can use ionotify() to request notification.
Unfortunately, I don’t have an example of this handy to give you.

Thanks for the response, David. Unfortunately this is not a resource
manager. I am working on a multi-platform IPC library so it has to
run in user program code.

If you run across any usage examples for ionotify(), please think of
me.

It is rather poorly documented so keep few hints in mind:

  • use POLLARM if you’re not sure what to use;
  • you have to rearm after each notification;
  • when you get notification you don’t know how much data has arrived;
  • therefore you have to drain input queue (by spinning in
    ionotify+whatever_you_use_to_drain) until ionotify returns ‘no more
    data’;

Basically you have to use something like

ionotify(a);

ionotify(z);
do {
waitforevent();
drain(x);
} while (ionotify(x) == MOREDATA)

I have attached (somewhat innatural but working) sample, which I used a
while ago to test ionotify() functionality. It allows you to wait for
either a pulse ( coming from timer in this case) or data on a socket.

  • igor

Previously, Igor Kovalenko wrote in qdn.public.qnxrtp.os:

Andrew Thomas wrote:
What is the appropriate mechanism for doing a MsgReceive() or a
select() that will inform me whenever any of the following occurs:
[…]
I have attached (somewhat innatural but working) sample, which I used a
while ago to test ionotify() functionality. It allows you to wait for
either a pulse ( coming from timer in this case) or data on a socket.

Thanks, Igor. I’ll give this a shot. A line of code is worth 10
lines of documentation sometimes.

Cheers,
Andrew