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?
Multithreading
Moderator: Coders of Rage
- Milch
- Chaos Rift Junior
- Posts: 241
- Joined: Sat Jul 11, 2009 5:55 am
- Programming Language of Choice: C++
- Location: Austria, Vienna
Multithreading
Follow me on twitter!
Re: Multithreading
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.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
Dad, "Yea well I have a fan belt in street fighting"
- Milch
- Chaos Rift Junior
- Posts: 241
- Joined: Sat Jul 11, 2009 5:55 am
- Programming Language of Choice: C++
- Location: Austria, Vienna
Re: Multithreading
So if I got it right - semaphores are locking a variable.
So the other thread still has to wait until its unlocked, right? =/
So the other thread still has to wait until its unlocked, right? =/
Follow me on twitter!