Timing puzzler

i’ve got a little puzzle on my current system…

i’ve got xfree compiling in the background while running some small tests
on my game. when running my game i notice i get a very choppy 2-40 fps (it
seems to get bogged under 10 fps quite a bit. if i add “SDL_Delay(10)” to
the main loop i get a fairly steady 37 fps.

this one has got me stumped. perhaps it is just random chance and i run the
game with the “delayed version” while the compiler is more IO bound? i’ve
been tinkering with it for about 1/2 hour and it has been very consistent
though.

if it helps explain anything, my kernel is a 2.4.19-pre with a lot of
patches (including preempt)?

i don’t know if this makes sense at all? perhaps my game should always have
some sort of small delay to share the cpu and give me smoother performance?
or perhaps it’s just sunflares or something and i shouldn’t worry about it?

Possibly the scheduler is recognizing your program as a CPU hog and bumping
it down in priority.On Sat, Jun 15, 2002 at 10:32:01AM -0700, Pete Shinners wrote:

i’ve got xfree compiling in the background while running some small tests
on my game. when running my game i notice i get a very choppy 2-40 fps (it
seems to get bogged under 10 fps quite a bit. if i add “SDL_Delay(10)” to
the main loop i get a fairly steady 37 fps.


Matthew Miller @Matthew_Miller http://www.mattdm.org/
Boston University Linux ------> http://linux.bu.edu/

i’ve got a little puzzle on my current system…

i’ve got xfree compiling in the background while running some small tests
on my game. when running my game i notice i get a very choppy 2-40 fps (it
seems to get bogged under 10 fps quite a bit. if i add “SDL_Delay(10)” to
the main loop i get a fairly steady 37 fps.

Updating graphics under X11 requires a context switch to the X server to
actually process graphics requests and display your video updates. If you
don’t put a short delay in your code, the kernel will run you as much as
possible, only transferring control to the X server occasionally. So…
if you put a small delay at the end of each frame, the kernel will transfer
control to another process (hopefully the X server) and you get smoother
visible animation.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

this could be done more directly with the yield system call
(or equivalent depending on your platform), but it wouldn’t
be portable.On Sun, 2002-06-16 at 13:06, Sam Lantinga wrote:

i’ve got a little puzzle on my current system…

i’ve got xfree compiling in the background while running some small tests
on my game. when running my game i notice i get a very choppy 2-40 fps (it
seems to get bogged under 10 fps quite a bit. if i add “SDL_Delay(10)” to
the main loop i get a fairly steady 37 fps.

Updating graphics under X11 requires a context switch to the X server to
actually process graphics requests and display your video updates. If you
don’t put a short delay in your code, the kernel will run you as much as
possible, only transferring control to the X server occasionally. So…
if you put a small delay at the end of each frame, the kernel will transfer
control to another process (hopefully the X server) and you get smoother
visible animation.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Sam,

I noticed that there are many places in SDL that call XSync which
will/should force the program to delay until the X server has processed
all the pending requests for that program. Can you tell us what SDL APIs
lead to calls to XSync?

		Bob Pendleton

Sam Lantinga wrote:>>i’ve got a little puzzle on my current system…

i’ve got xfree compiling in the background while running some small tests
on my game. when running my game i notice i get a very choppy 2-40 fps (it
seems to get bogged under 10 fps quite a bit. if i add “SDL_Delay(10)” to
the main loop i get a fairly steady 37 fps.

Updating graphics under X11 requires a context switch to the X server to
actually process graphics requests and display your video updates. If you
don’t put a short delay in your code, the kernel will run you as much as
possible, only transferring control to the X server occasionally. So…
if you put a small delay at the end of each frame, the kernel will transfer
control to another process (hopefully the X server) and you get smoother
visible animation.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-----------------------------------------+

  • Bob Pendleton, an experienced C/C++/Java +
  • UNIX/Linux programmer, researcher, and +
  • system architect, is seeking full time, +
  • consulting, or contract employment. +
  • Resume: http://www.jump.net/~bobp +
  • Email: @Bob_Pendleton +
    ±-----------------------------------------+

Sam,

I noticed that there are many places in SDL that call XSync which
will/should force the program to delay until the X server has processed
all the pending requests for that program. Can you tell us what SDL APIs
lead to calls to XSync?

Not offhand. SDL_Flip() and SDL_UpdateRects() do for sure. For more
detail, use the source, Luke. :slight_smile:

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment