c++visual-studio-2012windows-phone-8affinitysetthreadaffinitymask

Process affinity in Windows Phone


I WP library project, I am trying to bind the heavy-lifting process to the hardware thread (0 or 1). So the app consuming the library use other available core.

Can we set process affinity in Windows Phone 8 app? I cannot find documentation on something like SetProcessAffinity for WP8.


Solution

  • Processor affinity and a lot of hardware features are not accessible at a low-level on Windows Phone (and most mobile platforms) so that hardware can be upgraded over time (eg. future Windows Phone may have more than 2 cores) without causing app incompatibility.

    The solution is to use the abstracted libraries the platform provides which do the best job given the hardware at the time. For Windows Phone 8, some options are...

    1. Threads, ThreadPool and BackgroundWorker (covered in a previous answer)
    2. Async's Task.Run

    Microsoft's Channel 9 recently put up some videos which explain how and when to use async and other forms of threading.