[Tux4kids-tuxtype-dev] [Tuxmath-devel] Multithreading for rescaling title screen and menu items

David Bruce davidstuartbruce at gmail.com
Tue Jul 20 12:12:04 UTC 2010


Hi,

> Yep, SDL is pretty good at doing that so we don't have to :) I thought
> the pthreads code for the LAN game "just works" so I didn't even
> mention it, but so much the better if it stands to benefit as well.
> AFAIK it's a bit more involved than the rendering thread--are we doing
> anything "fancy" that might not be available from SDL?

I have to look back at it, but basically I'm pretty sure I didn't do
anything fancy, as it was the first and only time I have used
pthreads.  Initially, tuxmathserver was written solely as a standalone
program.  To run it in a thread, I made almost the entire contents of
tuxmathserver's main() into a function called RunServer(), which could
then be either called from the thread or wrapped in a minimal main()
function to run on its own.

This all still needs some work - one big issue is that the code isn't
really thread-safe in two main ways.  First, the data in mathcards.c
isn't thread-safe, as the question list and related variables are
limited to a single instance.  Second, if the server function in the
thread exits, it calls MC_EndGame(), as well as SDLNet_Quit(), which
brings down tuxmath itself.  If Joao Moriera had decided to work on
tuxmath instead of tuxpaint, it would have been his GSoC project to
straighten out these problems.


Best,

David



More information about the Tux4kids-tuxtype-dev mailing list