Multithreading

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
Milch
Chaos Rift Junior
Chaos Rift Junior
Posts: 241
Joined: Sat Jul 11, 2009 5:55 am
Programming Language of Choice: C++
Location: Austria, Vienna

Multithreading

Post 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?
Follow me on twitter!
alyosha
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 6
Joined: Sun Jan 03, 2010 6:37 am

Re: Multithreading

Post by alyosha »

User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: Multithreading

Post 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.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
Milch
Chaos Rift Junior
Chaos Rift Junior
Posts: 241
Joined: Sat Jul 11, 2009 5:55 am
Programming Language of Choice: C++
Location: Austria, Vienna

Re: Multithreading

Post 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? =/
Follow me on twitter!
Post Reply