32 bit overflow in timer

Bob Stewart robjsstewart at ...9...
Tue Feb 27 22:18:55 CET 2018


Hi Johannes,
That's interesting, I did the sizeof test on my base-hw kernel set up on 17.11 before I sent that reply.
Bob

Get Outlook for Android<https://aka.ms/ghei36>

________________________________
From: Johannes Kliemann <kliemann at ...543...>
Sent: Sunday, February 18, 2018 3:59:43 PM
To: genode-main at lists.sourceforge.net
Subject: Re: 32 bit overflow in timer

Hi Bob,

The long is not necessarily defined as 4 bytes. I have checked the GNU
reference manual [1] and it states

> The 32-bit unsigned long int data type can hold integer values in the range of at least 0 to 4,294,967,295. (Depending on your system, this data type might be 64-bit, in which case its range is identical to that of the unsigned long long int data type.) You may also refer to this data type as unsigned long.

So it can be 64bit long. I have tested this on x86_64 Linux and x86_64
Genode on NOVA and in both cases the sizeof(unsigned long) returned 8.
So it is a 64 bit integer type. I also tested this by assigning 2^32
which should yield 0 on a 32 bit type but it didn't.

Regarding this the overflow is most probably happening at some lower
level (I have not checked the exact implementation of the timer).

Regards,
Johannes

[1]:
https://www.gnu.org/software/gnu-c-manual/gnu-c-manual.html#Integer-Types

Am 18.02.2018 um 20:59 schrieb Bob Stewart:
> Johannes,
>
> Unsigned longs are 4 bytes. Unsigned long longs are 8 bytes. One byte
> equals 8 bits.
>
> Bob Stewart
>
>
> Get Outlook for Android <https://aka.ms/ghei36>
>
> ------------------------------------------------------------------------
> *From:* Johannes Kliemann <kliemann at ...543...>
> *Sent:* Sunday, February 18, 2018 6:01:36 AM
> *To:* Genode OS Framework Mailing List
> *Subject:* 32 bit overflow in timer
>
> Hi all,
>
> I noticed a 32 bit overflow in the Timer::Connection sleep functions and
> triggers.
> Calling usleep or trigger_once with an hour (3 600 000 000 us) works but
> calling it with two hours (7 200 000 000 us) causes something to
> overflow and stop the timer after 2 905 032 704 us which equals 7 200
> 000 000 & (2^32 - 1).
>
> As far as I have checked this these functions use the unsigned long
> which is indeed 64 bit but I think at some point only 32 bit are used.
>
> Is this intended behaviour?
> If so I think it would make sense to give out a warning at least.
>
> Regards,
> Johannes
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> genode-main mailing list
> genode-main at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/genode-main
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>
>
>
> _______________________________________________
> genode-main mailing list
> genode-main at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/genode-main
>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
genode-main mailing list
genode-main at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/genode-main
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.genode.org/pipermail/users/attachments/20180227/80166610/attachment.html>


More information about the users mailing list