Geeks With Blogs
Freestyle Coding Programming in the Real World

About a month ago, I was involved in a discussion1 on the App Hub Forums over threading on the Xbox 360. In order to save you the effort of digging through the forums2, I am providing a summary of the discussion.

The Xbox 360 has 3 processors. Each processor has 2 cores. The system reserves the first core on the first two processors. As such, you have access to cores 1, 3, 4 and 53. Your game starts on core 1. You can move it by calling

System.Threading.Thread.CurrentThread.SetProcessorAffinity( new int { X } );

where X is the zero-based number of the core. Granted, there is very little reason to move the main thread. You can move it, but it's more important to know where it lives.

With the Xbox 360, new threads start on the same core as the parent process. This means all your spawned threads start on core 1.4 If you want to get any real advantages out of the multiple cores, you have to manually move them to the other cores. A discussion on parallel processing, what makes a good candidate for a thread, et al is beyond the scope of this primer. However, I will be speaking on multi-threaded topics5 at DevLink this year6.

1Read: argument...
2Or the pain of reading all the yelling, screaming, name calling, and general mayhem
4Or, whatever thread you moved the main thread to run
5Ok, so that talk is on Multi-threaded Web Applications. However, some of the same principles apply.
6Nothing more than shameless self-promotion. Also, this means slide will be available later.

Posted on Friday, July 29, 2011 8:29 PM .NET , C# , XNA , Xbox 360 | Back to top

Comments on this post: Xbox 360 Threading Primer

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Chris Gardner | Powered by: