SDL for a 24/7 machine

Hi, I have a problem here. I just found out that my machine will be
operated 24/7 non stop. I know that this will make the timing and ticks
wrong. My questions are:

  1. Anybody know how to handle the ticks if it was run more than the ticks
    value can handle (Uint32 I believe)? FYI, I used ticks for animation and
    few other things so it is a crucial issue.

  2. Any other issue that would appear in the 24/7 non stop operation of an
    SDL application (SDL-wise or Linux-wise)? I know this is a rather abstract
    question, but I need your opinions and assumptions of what could go wrong
    so I could recognize the problem beforehand.

Thanks a lot in advance.

Fare thee well,
Bawenang R. P. P.----------------
ERROR: Brain not found. Please insert a new brain!

?Do nothing which is of no use.? - Miyamoto Musashi.

“I live for my dream. And my dream is to live my life to the fullest.”

if you are only on intel x86 you might try this
http://en.wikipedia.org/wiki/RDTSC but is non portable and seems that
it is not a good solution for newer cpus with variable frequencies or
multiple cores.

mattOn Tue, 18 Sep 2007 11:20:59 +0700 (WIT) benang at cs.its.ac.id wrote:

Hi, I have a problem here. I just found out that my machine will be
operated 24/7 non stop. I know that this will make the timing and
ticks wrong. My questions are:

  1. Anybody know how to handle the ticks if it was run more than the
    ticks value can handle (Uint32 I believe)? FYI, I used ticks for
    animation and few other things so it is a crucial issue.

  2. Any other issue that would appear in the 24/7 non stop operation
    of an SDL application (SDL-wise or Linux-wise)? I know this is a
    rather abstract question, but I need your opinions and assumptions of
    what could go wrong so I could recognize the problem beforehand.

Thanks a lot in advance.

Fare thee well,
Bawenang R. P. P.

Den Tue, 18 Sep 2007 11:20:59 +0700 (WIT)
skrev benang at cs.its.ac.id:

Hi, I have a problem here. I just found out that my machine will be
operated 24/7 non stop. I know that this will make the timing and
ticks wrong. My questions are:

  1. Anybody know how to handle the ticks if it was run more than the
    ticks value can handle (Uint32 I believe)? FYI, I used ticks for
    animation and few other things so it is a crucial issue.

Actually this might not be much of a problem, since differences wrap
around too thanks to two’s complement. For example:

Uint32 before = 4294967295;     // = (Uint32)-1
Uint32 after = 1;
printf("%u\n", after - before); // = 2

So as long as you don’t need tick differences bigger than 32 bits you
should be fine. If you do need bigger differences for some reason, you
could accumulate ticks:

//in stead of SDL_GetTicks() (call somewhat regularly):
Uint64 GetTicks64 (void) {
	static Uint64 ticks64 = 0;
	static Uint32 lasttick = 0;
	Uint32 currenttick = SDL_GetTicks();
	ticks64 += currenttick - lasttick; //works, as above
	lasttick = currenttick;
	return ticks64;
}

This will still wrap around after 18446744073709551616 ticks though =).
Apart from that it might work, assuming SDL doesn’t otherwise screw up
things when the 32-bit ticks wrap around. I don’t think it does,
though.

Also, if you don’t do it already, you could consider making your
program have a fixed logic rate, separate from the video framerate.
Everything would then depend on “logic ticks” in stead of clock ticks.

  1. Any other issue that would appear in the 24/7 non stop operation
    of an SDL application (SDL-wise or Linux-wise)? I know this is a
    rather abstract question, but I need your opinions and assumptions of
    what could go wrong so I could recognize the problem beforehand.

Well, Linux should be fine, as long as your program doesn’t have
memory/resource leaks and such. Don’t know about SDL.

  • Gerry

I use SDL for a machine which is also on 24/7.

A unsigned long is good for 49 days of use before it wraps, so if your machine is re-booted occasionally then you’ll be fine. If not, then the info already given on here will suffice.

You’re not using Windows which is also good news in some ways - if you WERE using Windows you’d have to reboot before your 49 days were up as it’d probably have fallen over or BSOD…

Ed> ----- Original Message -----

From: trick@icculus.org (Gerry Jo Jellestad)
To: sdl at lists.libsdl.org
Sent: Tuesday, 18 September, 2007 2:40:17 PM
Subject: Re: [SDL] SDL for a 24/7 machine

Den Tue, 18 Sep 2007 11:20:59 +0700 (WIT)
skrev benang at cs.its.ac.id:

Hi, I have a problem here. I just found out that my machine will be
operated 24/7 non stop. I know that this will make the timing and
ticks wrong. My questions are:

  1. Anybody know how to handle the ticks if it was run more than the
    ticks value can handle (Uint32 I believe)? FYI, I used ticks for
    animation and few other things so it is a crucial issue.

Actually this might not be much of a problem, since differences wrap
around too thanks to two’s complement. For example:

Uint32 before = 4294967295;     // = (Uint32)-1
Uint32 after = 1;
printf("%u\n", after - before); // = 2

So as long as you don’t need tick differences bigger than 32 bits you
should be fine. If you do need bigger differences for some reason, you
could accumulate ticks:

//in stead of SDL_GetTicks() (call somewhat regularly):
Uint64 GetTicks64 (void) {
    static Uint64 ticks64 = 0;
    static Uint32 lasttick = 0;
    Uint32 currenttick = SDL_GetTicks();
    ticks64 += currenttick - lasttick; //works, as above
    lasttick = currenttick;
    return ticks64;
}

This will still wrap around after 18446744073709551616 ticks though =).
Apart from that it might work, assuming SDL doesn’t otherwise screw up
things when the 32-bit ticks wrap around. I don’t think it does,
though.

Also, if you don’t do it already, you could consider making your
program have a fixed logic rate, separate from the video framerate.
Everything would then depend on “logic ticks” in stead of clock ticks.

  1. Any other issue that would appear in the 24/7 non stop operation
    of an SDL application (SDL-wise or Linux-wise)? I know this is a
    rather abstract question, but I need your opinions and assumptions of
    what could go wrong so I could recognize the problem beforehand.

Well, Linux should be fine, as long as your program doesn’t have
memory/resource leaks and such. Don’t know about SDL.

  • Gerry

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

  ___________________________________________________________

Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
now.
http://uk.answers.yahoo.com/

  1. Any other issue that would appear in the 24/7 non stop operation of an
    SDL application (SDL-wise or Linux-wise)? I know this is a rather abstract
    question, but I need your opinions and assumptions of what could go wrong
    so I could recognize the problem beforehand.

The problem is just at the moment of wrapping around, with little math
it can be avoided.
I don’t see any other problems as it’s just

On my own 24/7 system I use timestamps to calculate most of the
things, except for anything that is related to performance. In that
case, I will really just calculate ticks difference between before and
after some function (that really takes a couple ticks only).
If you are looking for some sort of “uptime” then timestamps would be the way.

Good luck!

Well, I used Via EPIA embedded but I think it’s still in the x86 family.
I’ve read the wiki but I don’t think I need them. What I meant was the
ticks that was returned from SDL_GetTicks() method. Thanks though.

matt wrote:

if you are only on intel x86 you might try this
http://en.wikipedia.org/wiki/RDTSC but is non portable and seems that
it is not a good solution for newer cpus with variable frequencies or
multiple cores.

matt

Hi, I have a problem here. I just found out that my machine will be
operated 24/7 non stop. I know that this will make the timing and
ticks wrong. My questions are:

  1. Anybody know how to handle the ticks if it was run more than the
    ticks value can handle (Uint32 I believe)? FYI, I used ticks for
    animation and few other things so it is a crucial issue.

  2. Any other issue that would appear in the 24/7 non stop operation
    of an SDL application (SDL-wise or Linux-wise)? I know this is a
    rather abstract question, but I need your opinions and assumptions of
    what could go wrong so I could recognize the problem beforehand.

Thanks a lot in advance.

Fare thee well,
Bawenang R. P. P.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Fare thee well,
Bawenang R. P. P.> On Tue, 18 Sep 2007 11:20:59 +0700 (WIT) @benang_at_cs.its.ac wrote:


ERROR: Brain not found. Please insert a new brain!

?Do nothing which is of no use.? - Miyamoto Musashi.

“I live for my dream. And my dream is to live my life to the fullest.”

Gerry JJ wrote:

Den Tue, 18 Sep 2007 11:20:59 +0700 (WIT)
skrev @benang_at_cs.its.ac:

Hi, I have a problem here. I just found out that my machine will be
operated 24/7 non stop. I know that this will make the timing and
ticks wrong. My questions are:

  1. Anybody know how to handle the ticks if it was run more than the
    ticks value can handle (Uint32 I believe)? FYI, I used ticks for
    animation and few other things so it is a crucial issue.

Actually this might not be much of a problem, since differences wrap
around too thanks to two’s complement. For example:

Uint32 before = 4294967295; // = (Uint32)-1
Uint32 after = 1;
printf("%u\n", after - before); // = 2

So as long as you don’t need tick differences bigger than 32 bits you
should be fine. If you do need bigger differences for some reason, you
could accumulate ticks:

//in stead of SDL_GetTicks() (call somewhat regularly):
Uint64 GetTicks64 (void) {
static Uint64 ticks64 = 0;
static Uint32 lasttick = 0;
Uint32 currenttick = SDL_GetTicks();
ticks64 += currenttick - lasttick; //works, as above
lasttick = currenttick;
return ticks64;
}

I see. So I guess I wouldn’t have to change my code after all.

This will still wrap around after 18446744073709551616 ticks though =).
Apart from that it might work, assuming SDL doesn’t otherwise screw up
things when the 32-bit ticks wrap around. I don’t think it does,
though.

Also, if you don’t do it already, you could consider making your
program have a fixed logic rate, separate from the video framerate.
Everything would then depend on “logic ticks” in stead of clock ticks.

I don’t quite understand. What do you mean about “logic ticks”?

  1. Any other issue that would appear in the 24/7 non stop operation
    of an SDL application (SDL-wise or Linux-wise)? I know this is a
    rather abstract question, but I need your opinions and assumptions of
    what could go wrong so I could recognize the problem beforehand.

Well, Linux should be fine, as long as your program doesn’t have
memory/resource leaks and such. Don’t know about SDL.

Well, I’m not quite sure about this. When I do a valgrind, there are
memory leaks. But none of them was caused by my own code, but instead
SDL’s. They are from these methods:

  1. SDL_SetVideoMode() method
  2. SDL_Init() method
  3. Mix_OpenAudio() method
  4. etc (forgot the rest but when I traced the valgrind’s log it’s not from
    any of my code)

BTW, actually there’s an issue in the machine when it was run for a week.
But I don’t know whether it was caused by SDL or not. My machine requires
inputs from the serial port. So, I made a routine to check for a serial
input asynchronously at the main loop. And then I used a custom
SDL_USEREVENT that was passed to the event queue if there is an input. The
problem is if the machine was run for a week and there’s a serial input,
the game crashed. The keyboard, mouse, etc didn’t work so I guess it’s not
an infinite loop issue. And IMHO it has got nothing to do with the
SDL_GetTicks(). I don’t know whether the cause is the serial handler
(because I used a pure C on a C++ object) or the SDL event handler or
maybe something else. I’m also confused because to test it, I need to wait
for a week until the problem comes up.

Thanks a lot.

Fare thee well,
Bawenang R. P. P.----------------
ERROR: Brain not found. Please insert a new brain!

?Do nothing which is of no use.? - Miyamoto Musashi.

“I live for my dream. And my dream is to live my life to the fullest.”

Thanks.

Can I ask a question? Because you also use it for a 24/7 machine, do you
have occasional crashes? Because that happened to mine. Although the issue
rarely happened, but it usually happens if the machine was run for a long
time. And it always happens when there’s an input from the serial port.
FYI, there’s a serial modem-like device that will send a sequence of chars
to the program when it was triggered.

Edward Byard wrote:> I use SDL for a machine which is also on 24/7.

A unsigned long is good for 49 days of use before it wraps, so if your
machine is re-booted occasionally then you’ll be fine. If not, then the
info already given on here will suffice.

You’re not using Windows which is also good news in some ways - if you
WERE using Windows you’d have to reboot before your 49 days were up as
it’d probably have fallen over or BSOD…

Ed

----- Original Message ----
From: Gerry JJ
To: sdl at lists.libsdl.org
Sent: Tuesday, 18 September, 2007 2:40:17 PM
Subject: Re: [SDL] SDL for a 24/7 machine

Den Tue, 18 Sep 2007 11:20:59 +0700 (WIT)
skrev @benang_at_cs.its.ac:

Hi, I have a problem here. I just found out that my machine will be
operated 24/7 non stop. I know that this will make the timing and
ticks wrong. My questions are:

  1. Anybody know how to handle the ticks if it was run more than the
    ticks value can handle (Uint32 I believe)? FYI, I used ticks for
    animation and few other things so it is a crucial issue.

Actually this might not be much of a problem, since differences wrap
around too thanks to two’s complement. For example:

Uint32 before = 4294967295;     // = (Uint32)-1
Uint32 after = 1;
printf("%u\n", after - before); // = 2

So as long as you don’t need tick differences bigger than 32 bits you
should be fine. If you do need bigger differences for some reason, you
could accumulate ticks:

//in stead of SDL_GetTicks() (call somewhat regularly):
Uint64 GetTicks64 (void) {
    static Uint64 ticks64 = 0;
    static Uint32 lasttick = 0;
    Uint32 currenttick = SDL_GetTicks();
    ticks64 += currenttick - lasttick; //works, as above
    lasttick = currenttick;
    return ticks64;
}

This will still wrap around after 18446744073709551616 ticks though =).
Apart from that it might work, assuming SDL doesn’t otherwise screw up
things when the 32-bit ticks wrap around. I don’t think it does,
though.

Also, if you don’t do it already, you could consider making your
program have a fixed logic rate, separate from the video framerate.
Everything would then depend on “logic ticks” in stead of clock ticks.

  1. Any other issue that would appear in the 24/7 non stop operation
    of an SDL application (SDL-wise or Linux-wise)? I know this is a
    rather abstract question, but I need your opinions and assumptions of
    what could go wrong so I could recognize the problem beforehand.

Well, Linux should be fine, as long as your program doesn’t have
memory/resource leaks and such. Don’t know about SDL.

Fare thee well,
Bawenang R. P. P.


ERROR: Brain not found. Please insert a new brain!

?Do nothing which is of no use.? - Miyamoto Musashi.

“I live for my dream. And my dream is to live my life to the fullest.”

Thanks for the reply.

I can’t quite follow what you’ve said. By timestamps I think you are
referring to RDTSC, right? I honestly didn’t know about that before I read
the wiki. So, any time related method in my application is based on
SDL_GetTicks(). Also, I don’t quite understand about what you call
"uptime" is?

Simon wrote:

  1. Any other issue that would appear in the 24/7 non stop operation of
    an
    SDL application (SDL-wise or Linux-wise)? I know this is a rather
    abstract
    question, but I need your opinions and assumptions of what could go
    wrong
    so I could recognize the problem beforehand.

The problem is just at the moment of wrapping around, with little math
it can be avoided.
I don’t see any other problems as it’s just

On my own 24/7 system I use timestamps to calculate most of the
things, except for anything that is related to performance. In that
case, I will really just calculate ticks difference between before and
after some function (that really takes a couple ticks only).
If you are looking for some sort of “uptime” then timestamps would be the
way.

Good luck!

Fare thee well,
Bawenang R. P. P.----------------
ERROR: Brain not found. Please insert a new brain!

?Do nothing which is of no use.? - Miyamoto Musashi.

“I live for my dream. And my dream is to live my life to the fullest.”

Hi

Nope, no problems with crashes, but in reality my machine is left running for around 30 days at a maximum before something happens and it needs re-booting.

I also use serial comms and have had a few problems, but that’s down to Windows

I guess it depends what you’re doing - my application is a gaming (slot) machine and I have a master 1ms ticker which I use to derive timers for various events, I used the same on embedded systems for many years, with no problems at all.

You might want to consider doing some “quiet-time” housekeeping, i.e. when the machine is not in use for a long period of time, see if anything can be cleaned up, variables reset, etc.

Kind Regards,
Ed> ----- Original Message -----

From: benang at cs.its.ac.id (benang@cs.its.ac.id)
To: A list for developers using the SDL library. (includes SDL-announce)
Sent: Wednesday, 19 September, 2007 7:48:57 AM
Subject: Re: [SDL] SDL for a 24/7 machine

Thanks.

Can I ask a question? Because you also use it for a 24/7 machine, do you
have occasional crashes? Because that happened to mine. Although the issue
rarely happened, but it usually happens if the machine was run for a long
time. And it always happens when there’s an input from the serial port.
FYI, there’s a serial modem-like device that will send a sequence of chars
to the program when it was triggered.

Edward Byard wrote:

I use SDL for a machine which is also on 24/7.

A unsigned long is good for 49 days of use before it wraps, so if your
machine is re-booted occasionally then you’ll be fine. If not, then the
info already given on here will suffice.

You’re not using Windows which is also good news in some ways - if you
WERE using Windows you’d have to reboot before your 49 days were up as
it’d probably have fallen over or BSOD…

Ed

----- Original Message ----
From: Gerry JJ
To: sdl at lists.libsdl.org
Sent: Tuesday, 18 September, 2007 2:40:17 PM
Subject: Re: [SDL] SDL for a 24/7 machine

Den Tue, 18 Sep 2007 11:20:59 +0700 (WIT)
skrev benang at cs.its.ac.id:

Hi, I have a problem here. I just found out that my machine will be
operated 24/7 non stop. I know that this will make the timing and
ticks wrong. My questions are:

  1. Anybody know how to handle the ticks if it was run more than the
    ticks value can handle (Uint32 I believe)? FYI, I used ticks for
    animation and few other things so it is a crucial issue.

Actually this might not be much of a problem, since differences wrap
around too thanks to two’s complement. For example:

Uint32 before = 4294967295;     // = (Uint32)-1
Uint32 after = 1;
printf("%u\n", after - before); // = 2

So as long as you don’t need tick differences bigger than 32 bits you
should be fine. If you do need bigger differences for some reason, you
could accumulate ticks:

//in stead of SDL_GetTicks() (call somewhat regularly):
Uint64 GetTicks64 (void) {
    static Uint64 ticks64 = 0;
    static Uint32 lasttick = 0;
    Uint32 currenttick = SDL_GetTicks();
    ticks64 += currenttick - lasttick; //works, as above
    lasttick = currenttick;
    return ticks64;
}

This will still wrap around after 18446744073709551616 ticks though =).
Apart from that it might work, assuming SDL doesn’t otherwise screw up
things when the 32-bit ticks wrap around. I don’t think it does,
though.

Also, if you don’t do it already, you could consider making your
program have a fixed logic rate, separate from the video framerate.
Everything would then depend on “logic ticks” in stead of clock ticks.

  1. Any other issue that would appear in the 24/7 non stop operation
    of an SDL application (SDL-wise or Linux-wise)? I know this is a
    rather abstract question, but I need your opinions and assumptions of
    what could go wrong so I could recognize the problem beforehand.

Well, Linux should be fine, as long as your program doesn’t have
memory/resource leaks and such. Don’t know about SDL.

Fare thee well,
Bawenang R. P. P.


ERROR: Brain not found. Please insert a new brain!

?Do nothing which is of no use.? - Miyamoto Musashi.

“I live for my dream. And my dream is to live my life to the fullest.”


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

  ___________________________________________________________

Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
now.
http://uk.answers.yahoo.com/

Hi,

BTW, I was told again that it not all the machines but a few build. FYI,
theres different version of the machines because of different types of
touchscreen drivers. The ones that crashed occasionally were using
openSUSE 10.0 while the other used 10.1. And the ones using 10.1 don’t
have any crashes (yet). So I guess it’s somewhat settled for now. Thanks
guys.

Edward Byard wrote:

Hi

Nope, no problems with crashes, but in reality my machine is left running
for around 30 days at a maximum before something happens and it needs
re-booting.

I also use serial comms and have had a few problems, but that’s down to
Windows

I guess it depends what you’re doing - my application is a gaming (slot)
machine and I have a master 1ms ticker which I use to derive timers for
various events, I used the same on embedded systems for many years, with
no problems at all.

You might want to consider doing some “quiet-time” housekeeping, i.e. when
the machine is not in use for a long period of time, see if anything can
be cleaned up, variables reset, etc.

Kind Regards,
Ed

Thanks.

Can I ask a question? Because you also use it for a 24/7 machine, do you
have occasional crashes? Because that happened to mine. Although the issue
rarely happened, but it usually happens if the machine was run for a long
time. And it always happens when there’s an input from the serial port.
FYI, there’s a serial modem-like device that will send a sequence of chars
to the program when it was triggered.

Edward Byard wrote:

I use SDL for a machine which is also on 24/7.

A unsigned long is good for 49 days of use before it wraps, so if your
machine is re-booted occasionally then you’ll be fine. If not, then the
info already given on here will suffice.

You’re not using Windows which is also good news in some ways - if you
WERE using Windows you’d have to reboot before your 49 days were up as
it’d probably have fallen over or BSOD…

Ed

Den Tue, 18 Sep 2007 11:20:59 +0700 (WIT)
skrev @benang_at_cs.its.ac:

Hi, I have a problem here. I just found out that my machine will be
operated 24/7 non stop. I know that this will make the timing and
ticks wrong. My questions are:

  1. Anybody know how to handle the ticks if it was run more than the
    ticks value can handle (Uint32 I believe)? FYI, I used ticks for
    animation and few other things so it is a crucial issue.

Actually this might not be much of a problem, since differences wrap
around too thanks to two’s complement. For example:

Uint32 before = 4294967295;     // = (Uint32)-1
Uint32 after = 1;
printf("%u\n", after - before); // = 2

So as long as you don’t need tick differences bigger than 32 bits you
should be fine. If you do need bigger differences for some reason, you
could accumulate ticks:

//in stead of SDL_GetTicks() (call somewhat regularly):
Uint64 GetTicks64 (void) {
    static Uint64 ticks64 = 0;
    static Uint32 lasttick = 0;
    Uint32 currenttick = SDL_GetTicks();
    ticks64 += currenttick - lasttick; //works, as above
    lasttick = currenttick;
    return ticks64;
}

This will still wrap around after 18446744073709551616 ticks though =).
Apart from that it might work, assuming SDL doesn’t otherwise screw up
things when the 32-bit ticks wrap around. I don’t think it does,
though.

Also, if you don’t do it already, you could consider making your
program have a fixed logic rate, separate from the video framerate.
Everything would then depend on “logic ticks” in stead of clock ticks.

  1. Any other issue that would appear in the 24/7 non stop operation
    of an SDL application (SDL-wise or Linux-wise)? I know this is a
    rather abstract question, but I need your opinions and assumptions of
    what could go wrong so I could recognize the problem beforehand.

Well, Linux should be fine, as long as your program doesn’t have
memory/resource leaks and such. Don’t know about SDL.

Fare thee well,
Bawenang R. P. P.


ERROR: Brain not found. Please insert a new brain!

?Do nothing which is of no use.? - Miyamoto Musashi.

“I live for my dream. And my dream is to live my life to the fullest.”


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

  ___________________________________________________________

Yahoo! Answers - Got a question? Someone out there knows the answer. Try
it
now.
http://uk.answers.yahoo.com/


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Fare thee well,
Bawenang R. P. P.> ----- Original Message ----

From: “@benang_at_cs.its.ac” <@benang_at_cs.its.ac>
To: A list for developers using the SDL library. (includes SDL-announce)
Sent: Wednesday, 19 September, 2007 7:48:57 AM
Subject: Re: [SDL] SDL for a 24/7 machine

----- Original Message ----
From: Gerry JJ
To: sdl at lists.libsdl.org
Sent: Tuesday, 18 September, 2007 2:40:17 PM
Subject: Re: [SDL] SDL for a 24/7 machine


ERROR: Brain not found. Please insert a new brain!

?Do nothing which is of no use.? - Miyamoto Musashi.

“I live for my dream. And my dream is to live my life to the fullest.”