Software development industry analysis by Larry O'Brien, the former editor of Software Development and Computer Language
Thursday, December 21, 2006

Ah, that's more like it. This is a graph of duration (in seconds) versus the number of threads during a calculation of a Mandelbrot set using the XNA Framework on the XBox 360 (Neil: The previous graph was normalized speed, as you suspected. For more on labeling the Axis in Office 12, see the next post.)

In order to have the XNA Framework distribute processing, you must explicitly set the "thread affinity." This must be done within the worker thread (presumably early in the ThreadStart delegate) and, on the XBox 360, you must not use the values 0 or 2, which are reserved. Thus, I use code like this:

 

struct ThreadWorker
{
    int processorAffinity;
    static int processorAffinityIterator = 0;
    internal ThreadWorker()
    {
        switch (processorAffinityIterator)
        {
            case 0  :
                processorAffinity = 1;
                break;
            case 1 :
                processorAffinity = 3;
                break;
            case 2 :
                processorAffinity = 4;
                break;
            case 3 :
                processorAffinity = 5;
                break;
            default :
                processorAffinity = 1;
                break;
        }
        if (++processorAffinityIterator == 4) { processorAffinityIterator = 0; }
    }
   internal void ThreadRun()
   {
     Thread.CurrentThread.SetProcessorAffinity(processorAffinity);
     ... begin work ...
Thursday, December 21, 2006 9:46:09 AM (Hawaiian Standard Time, UTC-10:00) |  Disqus link  | Concurrency | DotNet | Knowing | XBox360#
Tracked by:
"XNA Multithreading: Built On A Throne of Lies?" (Knowing.NET) [Trackback]
http://www.knowing.net/PermaLink,guid,4fff8db7-5977-4c2e-b620-4c11fdcfdffc.aspx [Pingback]
Search
About Larry...
Flickr photostream
Subscribe: RSS 2.0 Atom 1.0
Popular Articles
Programming Sabre with Java, C#, and XML
Genetic Programming in C#
15 Exercises To Know A Programming Language
Top 10 Things I've Learned About Computers From the Movies and Any Episode of "24"
Recently Published Articles
HI
KonaKoder
Categories
Archive
Admin Login
Sign In
Toolroll