Jump to content
  • Advertisement
Sign in to follow this  
KellerHood

The use of multithreading in a 2D SDL application?

This topic is 2299 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I like the idea of multithreading, and the idea of being able to perform multiple processes at one time. I can see how this would speed up a game significantly. But I just can't seem to come up with actually how to implement it.
How many threads should there be?
What would each do?
What should be controlled by each thread or another thread?
Would the threads be used for temporary, simultaneous events or for the entire length of runtime?

These are the main questions I'm having, basically about organization and what to actually put. What I'm thinking is have two runtime-length threads, one that performs physics and one that performs rendering, and then create a new thread on demand for things like dynamic resource loading/unloading, effects that I want to run simultaneous to the main loop, etc.

But I have no experience with such things. I need advice from someone who knows how to generally structure a multithreaded game.

Share this post


Link to post
Share on other sites
Advertisement

How many threads should there be?


At most, 1 active thread for each idle core on the target machine (ideally).


What would each do?
[/quote]

Whatever allows it the least interaction/blocking with the other threads, and least overhead of creating the thread in the first place.


Would the threads be used for temporary, simultaneous events or for the entire length of runtime?
[/quote]

Creating and destroying threads are non-trivial from a resource usage perspective. Threadpools are generally used for more short-term work. Even that has some overhead.


Multithreading is a large, subtle topic. How you want to lay things out makes sense and is fairly common. The devil is, as always, in the details.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!