Multithreading in Games
Posted 06 September 2006 - 10:33 AM
Posted 06 September 2006 - 11:16 AM
There are many patterns adressing this, but wich one depends on the current engine design.
Posted 06 September 2006 - 01:39 PM
Is there much of a performance boost if a game employs multithreading? I think (don't quote me) that Supreme Commander uses multithreading and I was just curious.
Posted 06 September 2006 - 01:57 PM
Posted 06 September 2006 - 02:27 PM
Games currently use threading mainly for I/O. You don't want the CPU to wait while reading a file into memory, or waiting for the next network packet to arrive. But this is typically handled by the libraries. Future games will definitely start using threading for reaching higher performance on multi-core CPUs.
Synchronization objects are just semaphores.
Posted 06 September 2006 - 03:04 PM
You could have your various threads, like main, rendering, physics. The most challenging issue is how data is handled between the threads as the physics threads could update the player object while it’s being rendered, showing the legs lying on the ground while the torso is still floating. Simply copying the data and the merge them back into a main branch is not desirable as this might override one threads mod by another, and you will never know the order. Also copying data get then a expensive operation, as it’s done up to once per frame.
There are many challenges in multiple threads, have fun exploring :)
Posted 07 September 2006 - 03:08 AM
Posted 07 September 2006 - 07:20 AM
achieve top-notch performance. However, I am finding that (in DirectX) by
using the Thread-safe flags when creating the device, simple discreet tasks
such as keeping graphics running steadily while loading files, and streaming
audio, become much simpler to write. However it could be a real nightmare to
try to convert some badly written old crap to effectively use multi-threading -
and unfortunately the games industry is full of this... the corollary of this is
'Design is everything'
Posted 07 September 2006 - 04:10 PM
think about it, how do you think sound / music is played WHILE other actions are taking place? in network-enabled modes, how do you think other players are able to make actions while you make actions "at the same time"?
the answer is multi-threading or event-polling.
either way, both are a kind of resource-sharing occuring [ideally] at split-second intervals to give the illusion of multi-threading. even with symmetric multi-processor systems, the operating system's kernel has to run in a "single-threaded" manner and assign processes [if able] to a "free" processor.
so to answer the question, "is there multi-threading in games?" sure there is. plenty of it! some systems use "real" multi-threading, some use event-polling. either way, it's being done.
and like Nick writes, you can accomplish challenging things with careful design.
Posted 08 September 2006 - 08:38 AM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users