Jump to content

View more

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

The use of multithreading in a 2D SDL application?

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 keelx   Members   

104
Like
0Likes
Like

Posted 29 March 2012 - 01:37 PM

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.

#2 Telastyn   Members   

3777
Like
0Likes
Like

Posted 29 March 2012 - 02:03 PM

How many threads should there be?


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

What would each do?


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?


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.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.