ok, i’m understanding this a little better now…and the mac thread
problems make sense now. i firuged there would be problems with them being
coorporative, but couldn’t think of how else to try and get things to work.
i know you mentioned the logical timer stuff before, but i just didn’t quite
understand enough; i do a bit better now. i guess i’m a little thick headed
sometimes. anyway, what about using the mac TimeManager to implement the
SDL_Addtimer and the SDL_Settimer ?? would this not work? and possibly
acomplish what i’m trying to do also? again, i’m not too familar with the
mac (obviously), but this seems like it should work. I guess i just see the
logical timer stuff and checking in the event loop to be messier and more of
a hastle than if i can find another way. but again, any comments or
suggestions are helpful. and if the logical timer is the best way to go in
the end…i’ll do it, but may need a little help in understanding it.
the way i see it now, is that if i have say 30 different timed events , i’d
have to check each time through the event processing loop to see if that
timed event should be processed, and if so do it?
thanks,
–Keith> On Tuesday, May 28, 2002, at 09:20 AM, Keith Swyer wrote:
hi, i’m trying to implement some sort of thread support for mac
(excluding
OSX). i know that only coorporative threading exists, but i am not sure
about semaphores and mutexes.
SDL has no thread support in Mac OS prior to Mac OS X. If you think
about it, semaphores and mutexes are useless for cooperative threads
anyways because you can only switch threads with a specific API call,
and can’t get preempted.
We can get some broken, rather useless threads on Mac OS 9 using the
MPLibrary. But then you cannot call any Mac OS API’s (this means SDL
API’s too) from within an MP thread because the majority of these API’s
are not thread-safe.
It’s been said before and I’ll say it again. You don’t need (and
shouldn’t want) threads to create this sort of application. You need
some sort of loop somewhere to check for events, so why not update your
timers in this loop, then draw any expired timers at that time? For
anything compute-bound on a single CPU (like blitting and running your
AI), multiple threads are going to be slower that a single thread.
Some games I’ve seen don’t use timers to control animation. They either
fix the framerate by SDL_Delay() the right amount every frame or they
control their animations with time-based movement calculations instead
of frame-based ones so they run at the same speed no matter what the
framerate is.
-D