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

Re: Context switching woes



Mark Collins wrote:

> I might have 3 threads, one for logic, one for rendering and one for
> networking. (I may merge the logic and rendering threads if there is no easy
> solution to this problem).

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

;-)

> When the renering thread is actually doing something, I don't want the logic
> 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...

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

> 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 drawbacks
> (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

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