   thread scheduling
  I'm writing a C#/XNA game and am thinking about how to implement the AI. My question is, if I write it as a separate thread, will that yield better performance than sticking something for AI in the main game loop? If I use a separate AI thread will that give more CPU time or will it just break up the same amount of CPU time between the main game thread and the AI thread?   
  Threading is good only if you can keep the interaction between threads as low as possible. In theory, you can get up to 2x the speed if you have a dual core or above CPU, since you can run one thread on each CPU core.If you find that you need to share data between the threads and have them interact frequently, then threading isn't a good option. What sort of AI are we talking about here?Threading would be good for something like pathfinding - you can have the thread queue a pathfinding request, and have it notify the main thread when it's done. The AI wouldn't move until the pathfinding is complete, but the main thread wouldn't be blocked waiting for it.   ;  In my case the AI is just about deciding when/where to send out fleets.My question though is about scheduling CPU time. For example, say I'm running mainGameThread getting 60% of the CPU time and windowsProcess getting the remaining 40% of CPU time. Then the game creates an AI thread. Will the CPU time be divided like 60% to the mainGameThread, 5% to the aiThread, and 35% for the windowsProcess, thus threading the AI will yield 5% more CPU time or will the aiThread take time away from the mainGameThread so it will be more like 55% for mainGamethread and 5% for aiThread?   ;  If you have a windows process that is taking up 40% of your CPU time then you have a problem. Generally you will have over 95% of the CPU available to you at all times and that will be split among whatever processes or threads you have which are runnable. The performance benefit of threading usually comes from when you have a CPU core doing essentially nothing, which means you can then use that core for 'free' processing. You shouldn't really be thinking of it in terms of competing with other processes for CPU time - it's the operating system's job to ensure each process gets the time that it needs - but in terms of taking up the slack in the available computing resources.   