Hi
I Want to make multithreading game. But i have never used multi threading, so Can anyone provide me information that how to make multithreading game ? I made games for mobile phones.
Hi
I Want to make multithreading game. But i have never used multi threading, so Can anyone provide me information that how to make multithreading game ? I made games for mobile phones.
Multithreaded programming doesn't seem as hard as it used to, but it's still challenging to wring the greatest amount of performance out of multiple processor cores.
Most games were designed to run in a single-threaded environment because of the state of the market i.e. a single CPU PC. Multi-threading incurs an overhead on the single CPU so game developers chose single threading. I think the difficulty they talk about is that they need to take apart the single thread game engine (i.e. the traditional infinite game loop - everything that happens up until you display a frame, then it starts all over again) and do some of those steps in parallel. The difficulty lies in resolving dependencies between steps in an iteration of a game loop to ensure they can happen exclusive of each other. Data also needs to be shared between threads so you have to ensure your objects/characters etc behave the same way as if the process was single threaded.
Your game starts and runs on a single thread, so all the tasks run sequentially one after the other. Thus, the total running time of a frame will be equal to the sum of the running times of each task done during that frame.
Using multiple threads would mean taking some of these tasks, and running them in parallel, at the same time as other tasks are running. In this configuration, the total running time of a frame will be roughly equal to the running time of the slowest of these parallel sets of tasks. Thus, the overall frame time is lower than when using a single thread, so the performance of the game is higher, yielding better framerates and smoother animations.
The only benefit to multithreading during the Update stage that I see would be to get update tasks done faster. But all the threads would have to finish up their work before moving on to drawing.
Bookmarks