Re: [AD] Timer interrupts and drawing

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Monday 25 August 2008, Colin Ward wrote:
> On 25/08/2008, you wrote:
> >> > On Monday 25 August 2008, Colin Ward wrote:
> >> >> I have a game here that is crashing and when I investigated it, it
> >> >>  is nstalling a timer with install_int() and in that timer's
> >> >>  callback it is alling drawing routines to draw things according to
> >> >>  the mouse's current osition.
> >> >>
> >> >> According to the documentation for install_int() you should
> >> >>  consider hat you are being called from an interrupt context, so am
> >> >>  I correct in hinking that calling drawing routines from a timer
> >> >>  callback is NOT llowed?
> >> >
> >> > Pretty much. In Windows and X, timers all run from a (single)
> >> >  separate hread, and in DOS, it all runs from an interrupt. Doing
> >> >  anything to omplex global data is bad, and doing more than a few
> >> >  basic instructions s also bad.
> >
> > I don't think he's using 4.9 yet. could be wrong though.
>
> No, I'm still on 4.2 (and soon 4.3).  When that is released I'll look into
> 4.9 support.
>
> This problematic code was found in a 3rd party game that my programming
> partner ported (I port Allegro, he ports the games) so I'll just have to
> tell him that the game itself is broken because it is doing lots of
> rendering in a timer callback.  I suppose on Windows/Linux and other
> platforms it just works out of luck.
>
> Interestingly though, I would expect timer based rendering to crash in OS
> routines called by graphics.c but it is actually crashing in src/mouse.c.
> It might be worth me doing some more research into this.  One thing about
> porting these not so well written games is that they do expose deficiencies
> in a port's implementation that you might not notice with a game that
> "follows the rules."

It crashing in the mouse handler is rather common in these cases, its caused 
by both the mouse code and the game code accessing the screen at the same 
time, or other changes being made that screw each other up. Multi threading 
isn't the easiest thing to get right when you know its a thread, but allegro 
hides the fact that timers execute in threads.


-- 
Thomas Fjellstrom
tfjellstrom@xxxxxxxxxx




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/