g+
g+ Communities
Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014 
<== Date ==> <== Thread ==>

Subject: RE: pend_io
From: "Hill, Jeff" <johill@lanl.gov>
To: "Ernest L. Williams Jr." <ernesto@slac.stanford.edu>
Cc: EPICS core-talk <core-talk@aps.anl.gov>
Date: Tue, 26 Jun 2012 18:26:07 +0000
> Is there a short tutorial that you can add somewhere?

I should expand the paragraph on ca_context_destroy in the manual to 
include some of this dialog.

Jeff

> -----Original Message-----
> From: Ernest L. Williams Jr. [mailto:ernesto@slac.stanford.edu]
> Sent: Tuesday, June 26, 2012 11:20 AM
> To: Hill, Jeff
> Cc: EPICS core-talk
> Subject: Re: pend_io
> 
> Hi Jeff,
> 
> This thread helped me as well?
> 
> Is there a short tutorial that you can add somewhere?
> 
> Your analogy also made it very clear. :)
> 
> 
> 
> Thanks,
> Ernest
> 
> 
> On 06/26/2012 10:12 AM, Hill, Jeff wrote:
> > Hi Steve,
> >
> >> I changed caget to caput :)
> >>
> >> The value was not written to my ioc
> >> int main (int argc, char *argv[])
> >> {
> >>          double  data=86;
> >>          chid        mychid;
> >>          SEVCHK(ca_create_channel(argv[1], NULL, NULL, 10,
> >>                            &mychid),"failure");
> >>          SEVCHK(ca_pend_io(10.0),"failure");
> >>          SEVCHK(ca_array_put(DBR_DOUBLE, 1, mychid,&data),"failure");
> >>          SEVCHK(ca_pend_io(10.0),"failure");
> >> }
> > It's true that ca_pend_io causes an implicit flush to occur (i.e the
> > equivalent of a call to ca_flush_io).
> >
> > A call to ca_flush_io is analogous to placing a letter in the mail box.
> > We know now that the problem of delivery is out of our hands and has
> been
> > entrusted to the postal service. So far so good, but the problem in
> > the above program is that a bomb has been dropped on our local postal
> > service before the letter can been delivered.
> >
> > When your program exits from main without calling ca_context_destroy
> > then the ca client library's send threads are very ungracefully
> > terminated before they have been given a chance to deliver any
> > message that they might have in their work queues to TCP. Furthermore,
> > it is very OS dependent what might happen to any undelivered TCP
> messages
> > lingering in the local IP kernel if you exit from main without given the
> > CA client library an opportunity to close its TCP sockets; we end up
> > with undefined behavior.
> >
> > In contrast, if the program calls ca_context_destroy before exiting
> > from main then the CA client library will gracefully shut down its
> > worker threads delivering all outstanding messages to the IP kernel
> > before they exit, and also gracefully close all of its sockets;
> > now we expect defined behavior.
> >
> > There is a (very brief) discussion of this issue in the troubleshooting
> > section of the CA reference manual - which perhaps could be expanded.
> >
> > The bottom line is if you shouldn’t terminate the local postal service
> > unless you provide also some additional funding for a close out :-)
> >
> > Jeff
> >
> >> -----Original Message-----
> >> From: core-talk-bounces@aps.anl.gov [mailto:core-talk-
> bounces@aps.anl.gov]
> >> On Behalf Of Steve Hunt
> >> Sent: Tuesday, June 26, 2012 7:49 AM
> >> To: core-talk@aps.anl.gov
> >> Subject: pend_io
> >>
> >> I have a problem running a trivial (too trivial it seems) ca client
> >> program.
> >>
> >> I fact I just generated the ca example using makeBaseApp.
> >>
> >> I changed caget to caput :)
> >>
> >> The value was not written to my ioc
> >>
> >> I am running 3.14.12.2, on linux_x86_64 but the behavior seems the same
> >> in older versions (at least 3.14.9(
> >>
> >> I am sending this to core-talk rather than tech-talk as this seems to
> be
> >> a real ca problem
> >>
> >>
> >>
> ##########################################################################
> >> #######3
> >> #include<stddef.h>
> >> #include<stdlib.h>
> >> #include<stdio.h>
> >> #include<string.h>
> >>
> >> #include<cadef.h>
> >>
> >> int main (int argc, char *argv[])
> >> {
> >>          double  data=86;
> >>          chid        mychid;
> >>
> >>          SEVCHK(ca_create_channel(argv[1], NULL, NULL, 10,
> >> &mychid),"failure");
> >>          SEVCHK(ca_pend_io(10.0),"failure");
> >>
> >>          SEVCHK(ca_array_put(DBR_DOUBLE, 1, mychid,&data),"failure");
> >>          SEVCHK(ca_pend_io(10.0),"failure");
> >> //      SEVCHK(ca_array_get(DBR_DOUBLE, 1, mychid,&data),"failure");
> >> //      SEVCHK(ca_pend_io(10.0),"failure");
> >> //      SEVCHK(ca_flush_io(),"failure");
> >> //      SEVCHK(ca_poll(),"failure");
> >>
> >> //      sleep(10);
> >> //      ca_context_destroy();
> >>
> >> //      return result;
> >> }
> >>
> >>
> >> When I un-comment ca_poll, ca_context_destroy, ca_get (plus its
> >> pend_io), or sleep!!!  it works!!!
> >>
> >> so  a ca_poll, a ca_context_destroy, or a ca_pend_io AFTER a ca_get,
> >> seems to flush the send buffer - but just ca_pend_io, nor ca_flush_io
> >> seem not to do so.
> >>
> >> At least the client example generated from makebaseApp should have a
> >> ca_put added, and made to work without the ca_get, but perhaps this
> >> could be considered a bug.
> >>
> >>
> >>
> >>
> >>
> >



References:
pend_io Steve Hunt
RE: pend_io Hill, Jeff
Re: pend_io Ernest L. Williams Jr.

Navigate by Date:
Prev: RE: pend_io Hill, Jeff
Next: RE: pend_io Hill, Jeff
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014 
Navigate by Thread:
Prev: Re: pend_io Ernest L. Williams Jr.
Next: Re: pend_io steve hunt
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014 
ANJ, 26 Nov 2012 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICSv4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·