Skip to main content
gamedev.net
🔒 Locked

Threads

Started by jonbell 0 replies 250+ views
Original Post
jonbell
jonbell
What are peoples thoughts on using threads in a gaming project. I can see the advantages but as i see it the possible debugging problems far outweigh them. Does anyone know for sure if any / many commercial gaming projects use multiple threads. If so how many and for which sub systems?
thona
thona
Well, IMHO it is a not too easy point for games. I would say they could be used more, but a significant amount of game developers are not comfortable with them. They are wonderfull for a number of things, but you are right, they CAN get you into trouble, and race conditions are extremely hard to debug. They have propably also not been used to often because most game computers just have one processor - which will change now with Hyperthreading coming, where one processor looks like two (and you gain performance by this).

OTOH, if you got for an architecture like Quake had, where the logic was running "separated" from the actual client (even for a single player game on just one computer), then running them two in two threads comes to you pretty naturally. A lot depends on what you actually can gain by using multiple threads. You can definitly decouple your logic from the rendering loop. But else? A lot depends on the topic of the game - whether there really are things which could be taken out of the main loop.

In regular applications multiple threads are normally used for two things (within one application):
(a) getting the UI more responsive. Tuis is not too hard to do, and could also be done in a game - even if your logic is pounding in the back, the UI is separate, the mouse moves etc.
(b) getting more things done at once. This is particularly true for a database server, a web server etc. where multiple users come in and work relatively unrelated (yes, database servers need to maintain locks etc. - I said relatively).

Now, (a) might be something for your game. But (b)? Does your game lead to a multithreaded algorythm?

BTW - I read somewhere that someone at intel said (tke this with a kilo of salt, but I agree on the topic) that Hyperthreading and multiple therads in games would propably be something left for the UI layer - using the reserves of the second thread to keep the framerate while thread one is handling the AI. And adding more animations :-)


Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)
RegardsThomas TomiczekTHONA Consulting Ltd.(Microsoft MVP C#/.NET)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.