Re: [AD] spin lock in xvtable.c

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


> In all the functions in xvtable.c, the first line of code is
> essentially a semaphore to allow for reentrant calls( i guess to make it
> multithreaded which it cant do anyway ).

This is indeed a semaphore, but not really for reentrant calls. It is
intended to detect when low-level drawing functions are called by high-level
drawing functions (for example, hline() by triangle()), thus allowing to
bypass the clipping and updating codes for the lower-level functions in this
situation, which results in a huge speed-up for the X11 driver.

> Since the code simply calls the same function again, it has the same
> functionallity as a while loop but with the overhead of a function call.
> This could also lead to a stack overflow if the function is called
> repeatedly.

It this was the case, the stack would instantly blow up on the first call to
a drawing primitive. But this is not what happens because
_xwin_vtable.putpixel is not the same as _xwin_putpixel (and so on).

You very likely misinterpreted the code in _xwin_replace_vtable(), which
saves the regular vtable (one of src/vtable*.c) in _xwin_vtable *before*
wiring the new vtable. The call stack is someting like this in 8bpp mode:
    _linear_putpixel8 (==_xwin_vtable.putpixel)
    _xwin_putpixel (==screen->vtable->putpixel)
    putpixel(screen, ...)
    main(...)

> Attached is a patch that simply changes the function call to a while loop.

I guess it will cause Allegro to hang on any high-level drawing primitive.

--
Eric Botcazou





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