Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Problems receiving pulses: (8 Items)
   
Problems receiving pulses  
Hi...

I have some trouble receiving a pulse (on the same node as the sender):

Client (abbreviated):
        struct _pulse pulse;
	chid = ChannelCreate(0);
	coid = ConnectAttach(0, 0, chid, _NTO_SIDE_CHANNEL, 0);
        MsgReceive(chid, &pulse, sizeof(pulse), NULL);

Server (abbreviated):
        MsgSendPulse (coid, prio, MY_PULSEID, 0);
(with coid the same value as on the client... has been sent to the server before.. cross checked this, value is same as 
used on client)

The problem is that the server sends the pulse without throwing an error, but on the client side, MsgReceive() never 
returns.

What could possibly go wrong here?

Thanks & Greetings,
 Marc
RE: Problems receiving pulses  
The coid is a per process thing, the server must do a ConnectAttach as well.  The pulse probably ends up somewhere else.


> -----Original Message-----
> From: Marc Roessler [mailto:community-noreply@qnx.com]
> Sent: April-29-09 12:11 PM
> To: ostech-core_os
> Subject: Problems receiving pulses
> 
> Hi...
> 
> I have some trouble receiving a pulse (on the same node as the sender):
> 
> Client (abbreviated):
>         struct _pulse pulse;
> 	chid = ChannelCreate(0);
> 	coid = ConnectAttach(0, 0, chid, _NTO_SIDE_CHANNEL, 0);
>         MsgReceive(chid, &pulse, sizeof(pulse), NULL);
> 
> Server (abbreviated):
>         MsgSendPulse (coid, prio, MY_PULSEID, 0);
> (with coid the same value as on the client... has been sent to the
> server before.. cross checked this, value is same as used on client)
> 
> The problem is that the server sends the pulse without throwing an
> error, but on the client side, MsgReceive() never returns.
> 
> What could possibly go wrong here?
> 
> Thanks & Greetings,
>  Marc
> 
> 
> _______________________________________________
> OSTech
> http://community.qnx.com/sf/go/post28365
> 
Re: RE: Problems receiving pulses  
how would I do this in detail?

Ok, I do a ConnectAttach() on the server.. I need a chid for this.. ok I could create my own channel for that.. and then
 send my pulse into that channel.. but how would this reach the client then? Why does the client send me his coid at all
 (for example, when sending an event structure to the server) when the server can't do anything with it? Somehow I think
 I'm missing an important detail here...
Re: RE: Problems receiving pulses  
On Wed, Apr 29, 2009 at 12:24:12PM -0400, Marc Roessler wrote:
> how would I do this in detail?
> 
> Ok, I do a ConnectAttach() on the server.. I need a chid for this.. ok I could create my own channel for that.. and 
then send my pulse into that channel.. but how would this reach the client then? Why does the client send me his coid at
 all (for example, when sending an event structure to the server) when the server can't do anything with it? Somehow I 
think I'm missing an important detail here...

I think most of the info you're looking for is in the
previous thread on ionotify.  The coid and rcvid are
used with MsgDeliverEvent() when the event is SIGEV_PULSE.
You can't use a coid from another process with MsgSendPulse.
RE: RE: Problems receiving pulses  
You client, instead of pass the "coid" to ther server, should pass the
"chid, pid" to the server, so the server could "ConnectAttach()" to the
channel the client is going to MsgReceive() on...

But, why is your sever "MsgSendPulse()" to your client? In most the
case, your client suppose to put that coid into a "pulse event", and
send the whole event to the server, and your sever, would
MsgDelieverEvent() it back to let the client know....

-xtang

> -----Original Message-----
> From: Marc Roessler [mailto:community-noreply@qnx.com] 
> Sent: Wednesday, April 29, 2009 12:24 PM
> To: ostech-core_os
> Subject: Re: RE: Problems receiving pulses
> 
> how would I do this in detail?
> 
> Ok, I do a ConnectAttach() on the server.. I need a chid for 
> this.. ok I could create my own channel for that.. and then 
> send my pulse into that channel.. but how would this reach 
> the client then? Why does the client send me his coid at all 
> (for example, when sending an event structure to the server) 
> when the server can't do anything with it? Somehow I think 
> I'm missing an important detail here...
> 
> _______________________________________________
> OSTech
> http://community.qnx.com/sf/go/post28367
> 
> 
Re: RE: RE: Problems receiving pulses  
Xiaodan, yes this is true, this would work using MsgDelieverEvent()...

But the problem is that in our case, the server needs to modify a part of the event (the value) before sending it back. 
Storing the client-supplied event in the (extended) OCB and modifying it each time before sending it back to the client 
is not so elegant...

So I'd rather try to do a MsgSendPulse() "manually".. and also I'd like to get an in depth understanding of what (and 
why) is happening internally, and this is a good chance to learn about it.



OK... so if I wanted to use MsgSendPulse myself, the client would send its chid and pid to the server. The nd and the 
pid could be read from the ctp struct... is this also contained in the ocb somewhere?

Then I would do on  the server:

  coid = ConnectAttach( client_nd, client_pid, client_chid, _NTO_SIDE_CHANNEL, NULL);
store this coid, and later:
  MsgSendPulse (coid,priority, MY_PULSEID, 0)

correct?

Now what I don't understand: as we just saw, the server needs client nd, pid and chid, in order to do a ConnectAttach() 
before sending a Pulse. Then why does the client not include this info in case we use Events (which are noting more than
 an abstraction of the above code)? Instead, the client packs his coid (!) into the event structure, and sends this to 
the server:
SIGEV_PULSE_INIT( ®_msg.ev, coid, SIGEV_PULSE_PRIO_INHERIT, MY_PULSEID, 0 );
This is what I don't get, and how I got onto the wrong track regarding coid/chid.. If the coid behaves like a file 
descriptor (i.e. only makes sense in that specific process), why would the client send it to the server?

And: isn't t the chid process specific as well?

Greetings,
 Marc

RE: RE: RE: Problems receiving pulses  
Marc,

I understand you confusion in MsgDelieverEvent(). 

MsgSendPulse() and MsgDelieverEvent() is different.

MsgSendPulse() need a "connection", to sent the pulse; If your server
want to MsgSendPulse() to client, your server need to establish a
connection (via  ConnectAttach()) with the client (well, with the
channel created by client). To establish this connection, you need the
"nd, pid, chid", which, you need the client to tell you.

In MsgDelieverEvent case, you don't need a connection "from server to
client", it is the kernel that based on the rcvid, the event type
(PULSE) and the coid inside the event, to find out exactly HOW to
deliver event (in this case, add a pulse into the channel so whoever
MsgReceive() to that channel would get the pulse). Ie, the knowledge
about "pulse event", "connection" ... are all inside the kernel, not
your server application.

This is done so because as you can see, the "event" could be something
else. A signal, an indication of an interrupt... And the server could
designed in a generic way (just MsgDelieverEvent() without knowing
what's in the event), and let the client decided how they want to be
"notified".

Being said that, since a pulse event can carry 32bit "value", and
sometime it is necessary to have server carry back some value to client.
So for a server, knowing (by design) client will only sent "pulse
event", and modify the "pulse value" before MsgDeliever() it back.  It
is not so elegant, but I wouldn't say it's 
totally wrong.

Hope this making sense now.

-xtang


> -----Original Message-----
> From: Marc Roessler [mailto:community-noreply@qnx.com] 
> Sent: Thursday, April 30, 2009 4:49 AM
> To: ostech-core_os
> Subject: Re: RE: RE: Problems receiving pulses
> 
> Xiaodan, yes this is true, this would work using MsgDelieverEvent()...
> 
> But the problem is that in our case, the server needs to 
> modify a part of the event (the value) before sending it 
> back. Storing the client-supplied event in the (extended) OCB 
> and modifying it each time before sending it back to the 
> client is not so elegant...
> 
> So I'd rather try to do a MsgSendPulse() "manually".. and 
> also I'd like to get an in depth understanding of what (and 
> why) is happening internally, and this is a good chance to 
> learn about it.
> 
> 
> 
> OK... so if I wanted to use MsgSendPulse myself, the client 
> would send its chid and pid to the server. The nd and the pid 
> could be read from the ctp struct... is this also contained 
> in the ocb somewhere?
> 
> Then I would do on  the server:
> 
>   coid = ConnectAttach( client_nd, client_pid, client_chid, 
> _NTO_SIDE_CHANNEL, NULL); store this coid, and later:
>   MsgSendPulse (coid,priority, MY_PULSEID, 0)
> 
> correct?
> 
> Now what I don't understand: as we just saw, the server needs 
> client nd, pid and chid, in order to do a ConnectAttach() 
> before sending a Pulse. Then why does the client not include 
> this info in case we use Events (which are noting more than 
> an abstraction of the above code)? Instead, the client packs 
> his coid (!) into the event structure, and sends this to the server:
> SIGEV_PULSE_INIT( ®_msg.ev, coid, 
> SIGEV_PULSE_PRIO_INHERIT, MY_PULSEID, 0 ); This is what I 
> don't get, and how I got onto the wrong track regarding 
> coid/chid.. If the coid behaves like a file descriptor (i.e. 
> only makes sense in that specific process), why would the 
> client send it to the server?
> 
> And: isn't t the chid process specific as well?
> 
> Greetings,
>  Marc
> 
> 
> 
> _______________________________________________
> OSTech
> http://community.qnx.com/sf/go/post28412
> 
> 
Re: RE: RE: RE: Problems receiving pulses  
Ahh ok now everthing fits in the puzzle...!

I had thought that MsgDeliverEvent was a _user space_ abstraction of the (for example) MsgSendPulse() "syscall" (such as
 fread() is for read()...). But as you said, the abstraction is done in the kernel, so the interface can be (and is) 
completely different. This makes perfect sense now, and you explained it quite well why this design was chosen.

I changed my code to MsgDeliverEvent, it works just fine now.

Thanks & Greetings,
 Marc