Results 1 to 2 of 2

Thread: Specifying processor affinity on a multicore machine for a specific thread

  1. #1
    Join Date
    Nov 2010
    Posts
    122
    Thanks
    62
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Cool Specifying processor affinity on a multicore machine for a specific thread

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Specifying processor affinity on a multicore machine for a specific thread

    May be you will find this interesting, even though it not much more than you already posted:
    http://developer.qt.nokia.com/faq/an...inity_in_linux
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. The following user says thank you to high_flyer for this useful post:

    bob2oneil (15th July 2011)

Similar Threads

  1. state machine in its own thread
    By shaolin in forum Qt Programming
    Replies: 7
    Last Post: 4th June 2011, 13:45
  2. changing thread affinity properly
    By mentalmushroom in forum Qt Programming
    Replies: 3
    Last Post: 3rd March 2011, 18:05
  3. Replies: 5
    Last Post: 21st August 2009, 15:10
  4. QProcess processor affinity
    By ibergmark in forum Qt Programming
    Replies: 1
    Last Post: 28th March 2008, 16:09
  5. Multi-thread vs. Multicore
    By TheGrimace in forum Qt Programming
    Replies: 10
    Last Post: 20th September 2007, 22:17

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.