Multithreading
Posted: Sun Jan 03, 2010 6:25 am
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?
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?