EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Subscription updates halting?
From: "Gibbs, Matt" <[email protected]>
To: Andrew Johnson <[email protected]>
Cc: "[email protected]" <[email protected]>
Date: Tue, 19 Nov 2013 13:19:58 -0800
Thanks for the info.

I am using node-ffi to create an interface between the libca C library, and the javascript code in my node.js server.  I am using preemptive callbacks right now, and when a libca monitor event callback fires, I run a javascript function.  After reading the channel access docs, I think the problem I am having is that node.js doesn’t like it when you call a javascript callback from anything but the main thread, and libca runs callbacks from its worker threads.  Sounds like I need to either disable preemptive callbacks, or come up with a more sophisticated way to deal with the multithreaded-ness of CA.

Back to the drawing board!
—Matt
On Nov 11, 2013, at 8:52 AM, Andrew Johnson <[email protected]> wrote:

> Hi Matt,
> 
> On 11/10/2013 04:46 AM, Gibbs, Matt wrote:
>> I have a simple test script where I create a channel, then create a
>> new subscription, and pass in an event callback function which just
>> prints the current value of the PV to the terminal.  Most of the
>> time, this works great, but maybe 20% of the time, I get two updates,
>> then nothing else for the duration of the program.  This is always
>> using the same code, with the same PV.  If I run ‘camonitor’ on the
>> PV repeatedly, I never see the same problem.
>> 
>> I don’t get any exception messages, and the rest of the script
>> doesn’t crash or halt, so it seems like the event callback just stops
>> getting called.
>> 
>> Any ideas about what might be happening, or things I can do to
>> further debug this?
> 
> As Dirk said its easier for us to help if you can show us the code, but 
> I can suggest a couple of possibilities.
> 
> Are you configuring the CA library to use pre-emptive callbacks or not? 
> See http://www.aps.anl.gov/epics/base/R3-14/12-docs/CAref.html#Thread 
> for an explanation. If you want libca run your callbacks from its 
> internal threads at any time (pre-emptive enabled) you must handle any 
> necessary locking to protect your data structures against race 
> conditions. If on the other hand you disable pre-emptive callbacks you 
> must call ca_pend_event() regularly because libca can only call your 
> event callbacks while your main thread is inside that routine.
> 
> Note that the callbacks will still happen in the context of those 
> internal libca threads, but you don't have to worry about using mutexes 
> to protect your data in most cases.
> 
> There is a difference between ca_pend_io() and ca_pend_event(); the 
> former will only result in monitor callbacks being run while the library 
> is waiting for channel connections and ca_get() and ca_put() operations 
> to complete. If the only I/O outstanding is waiting for monitor events 
> to fire, ca_pend_io() will return immediately without processing them, 
> thus you usually need to use ca_pend_event().
> 
> If that doesn't help we'll probably need to see your code to work out 
> what's going on.
> 
> - Andrew
> -- 
> Advertising may be described as the science of arresting the human
> intelligence long enough to get money from it. -- Stephen Leacock



References:
Subscription updates halting? Gibbs, Matt
Re: Subscription updates halting? Andrew Johnson

Navigate by Date:
Prev: Re: areaDetector for a Basler GigE camera Florian Sorgenfrei
Next: RE: areaDetector for a Basler GigE camera Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Subscription updates halting? Andrew Johnson
Next: Error while opening OPI Swati Soni2
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 20 Apr 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·