EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  <20042005  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  1999  2000  2001  2002  2003  <20042005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Proglem doing CA calls after catching a signal
From: Eric Norum <[email protected]>
To: Robert Soliday <[email protected]>
Cc: tech-talk <[email protected]>
Date: Mon, 26 Jul 2004 14:29:31 -0500
Robert Soliday wrote:

> int sigint=0;
.
.
.
/* wrapper for ca_pend_event that allows breaking out early if the
   flag is set from a signal handler. Unlike ca_pend_event, a timeout
   of zero will not be converted to infinity. */
long oag_ca_pend_event(double timeout, int *flag) {
  long status=ECA_NORMAL;

  if (timeout <= 0)
    ca_poll();
  while (timeout > 0) {
    if (*flag)
      return(status);
    if (timeout > 1) {
      status = ca_pend_event(1);
      timeout -= 1;
    } else {
      status = ca_pend_event(timeout);
      timeout = 0;
    }
  }

  return(status);
}

I'm not completely up to speed on the latest 'alias/noalias' state of C pointers, but I think that it would be safer to add some 'volatile' keywords to protect yourself from overzealous optimizers:


volatile int sigint = 0;
.
.
long oag_ca_pend_event(double timeout, volatile int *flag) {
.
.

--
Eric Norum                                 [email protected]
Advanced Photon Source                     Phone: (630) 252-4793
Argonne National Laboratory


Replies:
RE: Program calling CA from witrin a posix signal handler Jeff Hill
References:
Proglem doing CA calls after catching a signal Robert Soliday
Re: Proglem doing CA calls after catching a signal Eric Norum
Re: Proglem doing CA calls after catching a signal Till Straumann
Re: Proglem doing CA calls after catching a signal Chris Larrieu
Re: Proglem doing CA calls after catching a signal Robert Soliday

Navigate by Date:
Prev: Re: Proglem doing CA calls after catching a signal Robert Soliday
Next: Base on windows Steven Hunt
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  <20042005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Proglem doing CA calls after catching a signal Robert Soliday
Next: RE: Program calling CA from witrin a posix signal handler Jeff Hill
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  <20042005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 10 Aug 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·