Page 1 of 1

Multithreading

Posted: Sun Jan 03, 2010 6:25 am
by Milch
Hey!
So I'm thinking of implementing multithreading in my latest game.

I thought about it alot and came up with two solutions.

1. Make a rendering thread and a logic thread.
The problem is - that most of the time one of the threads will be idle.
Example: I'm rendering the scene with my thread - but cant go on with the logic thread because it would overwrite the actual variables beeing rendered -> messed up rendering.

2. Make somekind of a job system. So I have N-1 threads ( N is number of cores ).
Three of them doing jobs and on of them is the master thread. The master thread checks if job XY is done and job YX too, then it goes on and has new jobs.
The problem with this is: What happends when a thread is taking longer to process a job than the other thread? The master thread would go idle. Great -.-"

Has anyone experience in this and can tell me better solutions?

Re: Multithreading

Posted: Sun Jan 03, 2010 7:08 am
by alyosha

Re: Multithreading

Posted: Sun Jan 03, 2010 11:40 am
by avansc
those links are good but wont really help all that much unless you know a lot of other things. you should pick up any decent operating systems book.

Re: Multithreading

Posted: Sun Jan 03, 2010 5:27 pm
by Milch
So if I got it right - semaphores are locking a variable.
So the other thread still has to wait until its unlocked, right? =/