EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: dbcar() and dbcaStats() locking
From: Andrew Johnson <[email protected]>
To: <[email protected]>
Date: Fri, 8 Aug 2014 16:24:16 -0500
Hi Ralph,

On 08/08/2014 02:08 PM, Ralph Lange wrote:
> I am not afraid of miscounting at all...
> 
> My impression was dbcar() takes the lock to avoid a situation where
> another thread is changing the CA link into a DB or CONSTANT link
> while the investigation of CA properties is going on. The pointer to
> the cid would suddenly be invalid, and the ca_... functions that are
> dereferencing the pointer could easily segfault.

Looking at dbCaRemoveLink() the pca structure is still valid after the
statement plink->value.pv_link.pvt = 0; it gets queued up for the
dbCaTask() to call ca_clear_channel(pca->chid) which will happen at a
lower priority than the periodic scan task that normally calls
dbcaStats(). This means it should be safe on UP systems with priority
scheduling. Lightly loaded SMP systems may be a different matter though...

> In any case I don't see the justification for handling the cases
> different.

dbcar is a user command, so is run very infrequently and on demand only.
It can afford to delay the IOC slightly if this is necessary to prevent
problems in generating its output for the user.

Here at the APS dbcaStats() gets called every 30 seconds on every IOC to
update its $(IOC):dbcaCount and $(IOC):dbcaDisco status PVs (we have
similar PVs for calls to ascaStats() and seqcaStats()). I didn't want to
take a global lock in that circumstance, although I can see the
potential for the current code to cause a problem in some circumstances.

The dbCaTask already has a chan_count variable that could be turned into
an atomic variable, and adding a similar connection counter should be
relatively easy. Codeathon task for someone?

- Andrew
-- 
Advertising may be described as the science of arresting the human
intelligence long enough to get money from it. -- Stephen Leacock

References:
dbcar() and dbcaStats() locking Ralph Lange
Re: dbcar() and dbcaStats() locking Andrew Johnson
Re: dbcar() and dbcaStats() locking Ralph Lange

Navigate by Date:
Prev: Re: dbcar() and dbcaStats() locking Ralph Lange
Next: Array data in db files? Ralph Lange
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: dbcar() and dbcaStats() locking Ralph Lange
Next: Array data in db files? Ralph Lange
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 18 Aug 2014 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·