[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Pierre Phaneuf wrote:
> Keith Lucas wrote:
> > We're considering using threading systems to make our software a bit
> > easier to write and slightly more modular, and I was wondering what
> > the "state of the art" in systems design for games using threading
> > looks like.
> > Is it used?
> > Or is it still all too new fangled, like C++ was a bit ago?
> > Are people doing coarse threading: one to do the rendering, one to do
> > the AI, one to do the networking?
> > Or are they doing things like running a thread for every agent in the
> > world to do its own AI?
> > I can see plusses and minuses all up and down, I'm looking for some
> > datapoints...
> How can I say this? Here are some facts:
> - Threads only add overhead when used on a single processor machine
> - On a multiple processor machine, threads have bad cache coherency
> In short, threads are bad.
To put it anouther way... On a single CPU machine, if you decide within
your code how much time to spend on sound/AI/graphics/whatever then you
If you use threads, you are at the mercy of the operating systems to
schedule time for your tasks. You spend the rest of your *life* worrying
about why your sound daemon hasn't been run for the last 50 milliseconds - but
if you increase it's priority, the graphics NEVER runs...stuff like that.
On multiple CPU's, threads are OK (so long as your granularity is OK) - but
then you'll probably want your code to run nicely on single CPU machines - and
if it does, it's simplest to just ignore the second CPU rather than write two
versions of the code - one for uniprocessor and another for SMP.
Writing portable software using threads is nearly impossible (as I've found to
my cost) because a setup that may work with Linux's scheduler may suck badly
under Windoze, MacOS, BSD, etc.
If multiple CPU's every become *really* common - then it may be worth it...but
for now, people are buying custom-specialised CPU's (fancy sound cards, fancy
graphics cards, fancy modems, etc) - rather than having dumb peripherals and
doing everything in general-purpose CPU's.
This makes a lot of sense because you can do better graphics with 3 million
transistors of custom graphics chip than within 3 million transistors of
general purpose silicon.
That trend could change - but not for a few years I suspect.
Steve Baker HomeEmail: <email@example.com>
HomePage : http://web2.airmail.net/sjbaker1
Projects : http://plib.sourceforge.net
To unsubscribe, e-mail: firstname.lastname@example.org
For additional commands, e-mail: email@example.com
- From: Keith Lucas <firstname.lastname@example.org>
- Re: Threads
- From: Pierre Phaneuf <email@example.com>