EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

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

Subject: RE: MIPS epicsEventWaitWithTimeout(()
From: "Walters, M \(Malcolm\)" <[email protected]>
To: <[email protected]>
Date: Wed, 10 May 2006 08:42:39 +0100
Although other implementations may not be throwing exceptions, it
doesn't mean they are working as you expect. Casting double precision
numbers greater than LONG_MAX cannot work since there is no long
representation of them.

Running the following code using gcc on Linux shows that all in this
case the result of casting DBL_MAX to a long is LONG_MIN.

To write code that will always work, the value to be cast should be
compared to LONG_MAX first. To be really defensive, a case for negative
numbers, or those below LONG_MIN should also be added.

Malcolm


/* Test to show behaviour of casting of limits*/

#include "float.h"
#include "limits.h"

double dMax=DBL_MAX;
long lMax;

int main(int argc, char * argv[]){

    lMax=(long)dMax;
    printf("%e %d %d\n",dMax,lMax,LONG_MIN);
}



> -----Original Message-----
> From: Matt Rippa [mailto:[email protected]] 
> Sent: 10 May 2006 02:49
> To: [email protected]
> Subject: MIPS epicsEventWaitWithTimeout(()
> 
> Hi all,
> 
> We're getting a floating point exception running iocInit() on 
> a mips hkbaja47 with 3.14.8.2 exampleApp. Specifically this 
> is the "timerQueue" task. Tracking this down it points to 
> epicsEventWaitWithTimeout() inside 
> base-3.14.8.2/src/libCom/osi/os/vxWorks/osdEvent.c
> 
> The double timeOut passed in is DBL_MAX size (1.79769e+308) 
> and used to calculate a semTake timeout. Basically, semTake 
> and wait a very long time:
> 
> int ticks = timeOut*sysClkRateGet();
> status = semTake((SEM_ID)id,ticks);
> 
> The mips can't seem to handle the double to int conversion 
> and ends up with an FPE and I think it's FPE_INVALID_OP.
> 
> It can handle this when ticks is clipped to LONG_MAX*1.0. 
> LONG_MAX*1.1 fails. We're wondering if there's any other 
> gotchas if we do this for our mips targets?
> 
> Of course it would be better if we could all run the same 
> code. :-) Maybe we need to disable some FPE's for the mips? 
> Does EPICS rely on disabling FPE's for all tasks? 
> 
> 
> Many thanks,
> -Matt
> 
> 
> iocInit()
> Starting iocInit
> ##############################################################
> ##############
> ###  EPICS IOC CORE built on May  8 2006
> ###  EPICS R3.14.8.2 $R3-14-8-2$ $2006/01/06 15:55:13$
> ##############################################################
> ##############
> 
> FPE Exception
> Exception Program Counter: 0x80d3c22c
> Status Register: 0x30006701
> Cause Register: 0x0000003c
> Task: 0x80f20870 "timerQueue"
> iocInit: All initialization complete
> 
> 
> -> tt 0x80ac70f0
> 80024434 vxTaskEntry    +c  : epicsThreadSleepQuantum 
> (&epicsThreadCallEntryPoint, 80acf48c, 0, 0)
> 808cea18 epicsThreadSleepQuantum+78 : 
> epicsThreadCallEntryPoint (eeeeeeee, eeeeeeee, eeeeeeee, eeeeeeee)
> 808c2f04 epicsThreadCallEntryPoint+a4 : 
> timerQueueActive::run(void) (eeeeeeee, eeeeeeee, eeeeeeee, eeeeeeee)
> 808d4ee4 timerQueueActive::run(void)+40 : 
> epicsEvent::wait(double) (800cfb5c, eeeeeeee, eeeeeeee, eeeeeeee)
> 808c8804 epicsEvent::wait(double)+28 : 
> epicsEventWaitWithTimeout (eeeeeeee, 80acf494, 808c7a48, 80acfe10)
> --------------------------------
> 
> -> ti 0x80f20870
> 
>   NAME        ENTRY       TID    PRI   STATUS      PC       
> SP     ERRNO  DELAY
> ---------- ------------ -------- --- ---------- -------- 
> -------- ------- -----
> timerQueue 80d3c028     80f20870 129 SUSPEND    80d3c22c 
> 80f205b8       0     0
> 
> stack: base 0x80f20870  end 0x80f1d990  size 11840  high 1464 
>   margin 10376
> 
> options: 0xc
> VX_DEALLOC_STACK    VX_FP_TASK
> 
> $0   =                0   at   = ffffffff80d60000   v0   =    
>            3c
> v1   = ffffffff80f20870   a0   = ffffffff80f28c90   a1   =    
>             0
> a2   =         7fefffff   a3   = ffffffffffffffff   t0   =    
>      30006701
> t1   =         30006700   t2   =                4   t3   =    
>             0
> t4   =                0   t5   =                0   t6   =    
>             0
> t7   =                0   s0   = ffffffff80f28c90   s1   = 
> ffffffff80f20870
> s2   = ffffffff80f28e6c   s3   = ffffffff80d34080   s4   =    
>             0
> s5   =                0   s6   =                0   s7   =    
>             0
> t8   =                0   t9   =                0   k0   = 
> 8007823ceeeeeeee
> k1   =                0   gp   = ffffffff80119dd8   sp   = 
> ffffffff80f205b8
> s8   =                0   ra   = ffffffff80d3c21c
> sr   = 30006701           pc   = 80d3c22c
> 
> 
> fpcsr  =  1000014
> fp0    =      Inf   fp2    =        2   fp4    = 6.31152e+08  
>  fp6    =        0
> fp8    =        0   fp10   =        0   fp12   =        0   
> fp14   =        0
> fp16   =        0   fp18   =        0   fp20   = 1.79769e+308 
>   fp22   =        0
> fp24   =        0   fp26   =        0   fp28   =        0   
> fp30   =        0
> 
> FPE Exception
> Exception Program Counter: 0xvalue = 80d3c22c0
> Status Register: 0x = 0x30006701
> Cause Register: 0x00000003c
> 
> 
> 


Navigate by Date:
Prev: MIPS epicsEventWaitWithTimeout(() Matt Rippa
Next: RE: MIPS epicsEventWaitWithTimeout(() Jeff Hill
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: MIPS epicsEventWaitWithTimeout(() Jeff Hill
Next: June EPICS Meeting reminder Andrew Johnson
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Sep 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·