EPICS Home

Experimental Physics and Industrial Control System


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

Subject: How do you know if you are accessing a shared resource?
From: Steven M Beard <[email protected]>
To: Epics Questions <[email protected]>
Date: Fri, 23 Jul 1999 11:03:17 +0100 (BST)
I have come across an interesting problem with EPICS records that allow
you to specify a user-defined function. Suppose, for the sake of this
example, you take a genSub record with an integer output

     +--------+
     | genSub |
     |        +-OUTA-
     |        |
     +--------+
     FTVA: LONG
     SNAM: myFunction

and your user defined function writes to its VALA field like this

     long myFunction( struct genSubRecord *pgensub )
     {
         *(long *)pgensub->vala = value;
         return 0;
     }

You can connect the OUTA link to a field in another record and that field
will be set to your value when the genSub processes. This works ok, but
now suppose you have arranged your database with multiple copies of the
genSub record all writing to the same database field, like this

     +--------+
     | genSub |
     |        +-OUTA-------+
     |        |            |
     +--------+            |
     FTVA: LONG            |
     SNAM: myFunction      |
                           |
     +--------+            |              +--------+
     | genSub |            |              | longin |
     |        +-OUTA-------+----------VAL-+        |
     |        |            |              +--------+
     +--------+            |
     FTVA: LONG            |
     SNAM: myFunction      |
                           |
     +--------+            |
     | genSub |            |
     |        +-OUTA-------+
     |        |
     +--------+
     FTVA: LONG
     SNAM: myFunction

Now all of a sudden you have three copies of myFunction all sharing the
same resource, and if the genSub records happen to process at the same
time there can be a clash. I had a database like this and saw some very
strange behaviour (a different record generating an "illegal choice"
message when I tried to write a valid value to one of its inputs) until I
explicitly protected pgensub->vala with a mutex semaphore. I have the
following questions: 

1) How can myFunction tell that the output field it is writing to is
   connected to a shared resource? This depends on how the database has
   been connected up.

2) Can EPICS handle such resource sharing transparently? It would be a lot
   easier to deal with if shared links like this are recognised and
   protected with a mutex semaphore automatically.

   I am using EPICS 3.12.2. Is the behaviour different in EPICS 3.13?

3) Am I missing something? Is there a technique I should be following
   to protect the shared resource automatically (e.g. using the PHAS field
   or something similar)?

Any advice gratefully received.

Steven

==============================================================================
Steven Beard
UK Astronomy Technology Centre
Royal Observatory                  Tel.   : +44 (0)131 668 8253 (direct)
Blackford Hill                              +44 (0)131 668 8100 (switchboard)
Edinburgh EH9 3HJ                  Fax.   : +44 (0)131 668 1130
UK                                 E-mail : [email protected]       (Internet) 
                                   WWW    : http://www.roe.ac.uk/smbwww/



Replies:
Re: How do you know if you are accessing a shared resource? Marty Kraimer

Navigate by Date:
Prev: Re: String PVs and the Portable CA Server. saa
Next: Re: How do you know if you are accessing a shared resource? William Lupton
Index: 1994  1995  1996  1997  1998  <19992000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: EPICS CA server and also GDD issues Jeff Hill
Next: Re: How do you know if you are accessing a shared resource? Marty Kraimer
Index: 1994  1995  1996  1997  1998  <19992000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024