Original Post
Hi Guys, I’ve been thinking about threading in games recently since the switch to multi-core processors. I've done concurrent programming at University so I know what problems can arise. But I only have experience with Java threading. And only want to deal with monitors when using shared resources. I'll be using ANSI C++ for implementation. I've got a few questions: 1. What would be the best multi-platform threading approach? I'd like my code to be as portable as possible. Would I just use OS specific preprocessor directives to include the appropriate implementations? This is how I am currently proposing to implement my threads at the moment. 1b. What about using .NET threads? What would the performance of running unmanaged code in a .NET thread be like? 2. What elements of my game could I thread? I've been thinking about this & the main candidate for threading would be AI. Are there any other sub-systems that would be good candidates to thread? Using threads for sub-systems would give rise to synchronization problems though? 2b. Will the main performance increase come from threading at the algorithm level? E.g. using 2 separate threads for calculating weights of 2 branches of a tree? If this is the case then programming games will be very difficult as the game world would become a shared resource & I would have to use monitors? They are hard to implement & hard to debug. Any suggested reading? Books or articles? Thanks for any advice given!