EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

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

Subject: FW: sysAtReboot
From: "Jeff Hill" <[email protected]>
To: <[email protected]>
Date: Wed, 16 Nov 2005 14:30:44 -0700

-----Original Message-----
From: Andrew Johnson [mailto:[email protected]] 
Sent: Friday, January 07, 2005 9:12 AM
To: Ernest L. Williams Jr.
Cc: EPICS tech-talk
Subject: Re: sysAtReboot


Ernest L. Williams Jr. wrote:
> 
> What is sysAtReboot introduced in EPICS R3.14.7?
> 
> Below is the message I received from Kay Kasemir when testing: 
> ==================================================================
> When loading the IOC application, one of the C++
> constructors in EPICS base complains
> "sysAtReboot not found. epicsExit will not be called by reboot".

I guess we should have documented this better, which if present is used by 
the new epicsExit() subsystem in R3.14.7.

I added the following code to the APS vxWorks BSPs:

/* This gives a rebootHook for EPICS before netLib has been shut down,
  * and also runs the C++ static desctructors of all loaded modules */
VOIDFUNCPTR _func_sysRebootHook = NULL;

static int sysRebootHook(int startType) {
     if (_func_sysRebootHook)
         (*_func_sysRebootHook)();
         cplusDtors(0);
     return OK;
}

int sysAtReboot(VOIDFUNCPTR closedown) {
     if (closedown && _func_sysRebootHook) return ERROR;
     _func_sysRebootHook = closedown;
     return OK;
}

The vxWorks reboot hooks are executed in the order in which they are 
registered, whereas it would make a lot more sense if they were executed 
in reverse order.  WRS have shown no inclination to fix this bug (which 
they even document as a bug IIRC), so I now register a reboot hook routine 
*before* netLibInit() gets run (from the same routine where I configure 
the network memory pool):

     rebootHookAdd(sysRebootHook);

By registering a reboot hook routine there, libCom's epicsExit() subsystem 
can call the routines registered with epicsAtExit() before the vxWorks 
network gets shut down by its hook routine, and as a result CA circuits 
close down nicely whenever you do a Control-X reboot.  It also calls all 
the C++ static destructors as well.

It is not strictly necessary to add the above code to your BSPs; EPICS 
will work exactly as it always has without this, with the exception of the 
warning message that Kay reported.  Having it there does make vxWorks IOCs 
slightly better network citizens though, and may reduce some delays when 
the rebooted IOC comes up.

- Andrew
-- 
Dear God, I didn't think orange went with purple until I saw the sunset you
made last night.  That was really cool. - Caro


Navigate by Date:
Prev: FW: Possible bug in taskwd Jeff Hill
Next: FW: error log facility Jeff Hill
Index: 2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: FW: Possible bug in taskwd Jeff Hill
Next: converging Jeff Hill
Index: 2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Feb 2012 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·