EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

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

Subject: Re: [Merge] ~freddie-akeroyd/epics-base:fix_win32_monotonic_time into epics-base:7.0
From: Freddie Akeroyd via Core-talk <core-talk at aps.anl.gov>
To: mp+391018 at code.launchpad.net
Date: Tue, 29 Sep 2020 23:23:56 -0000

Diff comments:

> diff --git a/modules/libcom/src/osi/os/WIN32/osdMonotonic.c b/modules/libcom/src/osi/os/WIN32/osdMonotonic.c
> index cb84643..208c1aa 100644
> --- a/modules/libcom/src/osi/os/WIN32/osdMonotonic.c
> +++ b/modules/libcom/src/osi/os/WIN32/osdMonotonic.c
> @@ -39,15 +42,10 @@ epicsUInt64 epicsMonotonicResolution(void)
>  epicsUInt64 epicsMonotonicGet(void)
>  {
>      LARGE_INTEGER val;
> -    if(osdUsePrefCounter) {
> -        if(!QueryPerformanceCounter(&val)) {
> -            errMessage(errlogMinor, "Warning: failed to fetch performance counter\n");
> -            return 0;
> -        } else
> -            return val.QuadPart;
> +    if(!QueryPerformanceCounter(&val)) {
> +        cantProceed("epicsMonotonicGet: Failed to read Windows Performance Counter\n");
> +        return 0;
>      } else {
> -        epicsUInt64 ret = GetTickCount();
> -        ret *= 1000000;
> -        return ret;
> +        return (epicsUInt64)(val.QuadPart * perfCounterScale + 0.5); /* return value in nanoseconds */

What one would probably like to do is   1000000000 * val.QuadPart / freq.QuadPart  in pure integer arithmetic, but the first bit will overflow quite soon. We could do   1e9 * ((double)val.QuadPart / (double)freq.QuadPart)    but I happened to choose   val.QuadPart * (1e9 / (double)freq.QuadPart)   which in this case looks to be   val.QuadPart * 100.0   but i'm not sure everything will always be this nice (hence the 0.5 rounding too). Would it would be more accurate to do ((double)val / (double)freq) or not make much difference? If freq can sometime be an awkward number would that be better?

>      }
>  }


-- 
https://code.launchpad.net/~freddie-akeroyd/epics-base/+git/epics-base/+merge/391018
Your team EPICS Core Developers is subscribed to branch epics-base:7.0.

References:
[Merge] ~freddie-akeroyd/epics-base:fix_win32_monotonic_time into epics-base:7.0 Freddie Akeroyd via Core-talk

Navigate by Date:
Prev: Re: [Merge] ~freddie-akeroyd/epics-base:fix_win32_monotonic_time into epics-base:7.0 mdavidsaver via Core-talk
Next: Re: [Merge] ~freddie-akeroyd/epics-base:fix_win32_monotonic_time into epics-base:7.0 Freddie Akeroyd via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  <20202021  2022  2023  2024 
Navigate by Thread:
Prev: Re: [Merge] ~freddie-akeroyd/epics-base:fix_win32_monotonic_time into epics-base:7.0 mdavidsaver via Core-talk
Next: Re: [Merge] ~freddie-akeroyd/epics-base:fix_win32_monotonic_time into epics-base:7.0 Freddie Akeroyd via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  <20202021  2022  2023  2024 
ANJ, 29 Sep 2020 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·