PDA

View Full Version : Specifying processor affinity on a multicore machine for a specific thread



bob2oneil
14th July 2011, 19:23
Does anyone know a way within Qt to have a particular high priority thread run on a particular processor for a
system with say a quad core processor.

Under Windows, there is an API called SetThreadAffinityMask(), which is documented as setting the
processor affinity mask for the specified thread. This API does not exist in the current Qt
code base, so I assume that perhaps there may be no direct support and Qt does not have a
cross platform wrapper.

I would need support for both desktop Linux and Windows XP.

Here is the details on SetThreadAffinityMask.


A thread affinity mask is a bit vector in which each bit represents a logical processor that a thread is allowed to run on. A thread affinity mask must be a subset of the process affinity mask for the containing process of a thread. A thread can only run on the processors its process can run on. Therefore, the thread affinity mask cannot specify a 1 bit for a processor when the process affinity mask specifies a 0 bit for that processor.

high_flyer
15th July 2011, 15:33
May be you will find this interesting, even though it not much more than you already posted:
http://developer.qt.nokia.com/faq/answer/setting_thread_processor_affinity_in_linux