[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Context switching woes

----- Original Message -----
From: Pierre Phaneuf <pp@ludusdesign.com>
Newsgroups: sunsite.linux.linuxgames
To: <linuxgames@sunsite.dk>
Sent: Monday, February 19, 2001 3:11 PM
Subject: Re: Context switching woes

> I'd say you should also merge the networking thread, but that's just me.
> See my signature and this:
> http://www3.sympatico.ca/pphaneuf/thread.html
> ;-)

FUD :-)

> > When the renering thread is actually doing something, I don't want the
> > thread to feed data to the scenegraph API, to prevent items moving
> > mid-render, and screwing everything up. Writing a simple lock mechanism
> > would work fine on a single processor, but if the game is run on a
> > multi-processor system, who knows what the scheduler is doing.
> Seems like the scenegraph needs to be protected by a lock. Simple, no?
> Well, as simple as it gets when you're involving threads...

It depends. The is a small chance (say, 1 in a billion) that there could be
a context swicth when the lock check is being done, and 2 subsystems getting
a lock at the same time.

> What do you mean about that lock working on a single processor, but not
> on a multi-processor system?

If 2 different threads are running on two different processors, the chance
of a context switch at the worst possible moment in time increases.

> > Under Windoze, you can tell the scheduler to give the current thread all
> > access (i.e. don't change the context at all). While this has some
> > (it freezes all the other threads), it does make coding thread-safe
> > functions a lot easier.
> Yeah, right, welcome to DeadLockFest 2001! ;-)


> --
> "A computer is a state machine. Threads are for people who can't
> program state machines." -- Alan Cox

Hmm, I wonder is AC is releated to Tony Cox (head of DirectX development,
who I'm exchanging a lot of emails with atm)

The Infamous Mark 'Nurgle' Collins
Lead Author - 'Linux Game Programming' (ISBN: 0-7615-3255-2)
WWW: http://www.thisisnurgle.org.uk Mobile: +44 7761 774 152
Email: me@thisisnurgle.org.uk  Spam: spam@thisisnurgle.org.uk

To unsubscribe, e-mail: linuxgames-unsubscribe@sunsite.dk
For additional commands, e-mail: linuxgames-help@sunsite.dk