Results 1 to 6 of 6

Thread: How set a processor affinity mask for the specified thread?

  1. #1
    Join Date
    Aug 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default How set a processor affinity mask for the specified thread?

    Hi

    I need sets a processor affinity mask for the specified thread.
    In MS VC I can do this by function SetThreadAffinityMask.
    But I can't find same function in QT

    Somebody can help me?

    Thanks!

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How set a processor affinity mask for the specified thread?

    From Qt Docs :
    void QObject::moveToThread ( QThread * targetThread )
    Changes the thread affinity for this object and its children. The object cannot be moved if it has a parent. Event processing will continue in the targetThread.

  3. #3
    Join Date
    Jul 2008
    Location
    London, UK
    Posts
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How set a processor affinity mask for the specified thread?

    Hiya,

    I don't think "moveToThread" is what is needed here. That will make the "owner" of that object the thread specified (which changes the way events and signal/object marshalling are handled).

    What is required, I think, is the ability to say "this thread runs on this processor". I'm not sure that this is possible in Qt but the QtConcurrent framework should handle some of these problems (it will map an algorithm across multiple CPU's taking care of the threading for you).

    I'm afraid I'm not sure there's any way of handling processor inside Qt.

    @Ritor. What functionality are you trying to achieve here?

  4. #4
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How set a processor affinity mask for the specified thread?

    Sorry !!
    I Overlooked, he need to set Processor affinity not Thread affinity.
    Anyway I don't think so thats possible in Qt in platform independent way.

  5. #5
    Join Date
    Aug 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How set a processor affinity mask for the specified thread?

    I have several thread. And I need to one thread execute on one core (processor) and the second thread execute on second core (processor).

    I think QtConcurrent perform another function. Or I mistaken?

  6. #6
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How set a processor affinity mask for the specified thread?

    Quote Originally Posted by Ritor View Post
    I have several thread. And I need to one thread execute on one core (processor) and the second thread execute on second core (processor).
    This is handled by OS not be program. And on most of the OS this is default behavior. Means If we created a threaded app. Then all cores of CPU will be utilized equally.

    Quote Originally Posted by Ritor View Post
    I think QtConcurrent perform another function. Or I mistaken?
    Programs written with QtConcurrent automatically adjust the number of threads used according to the number of processor cores available.

Similar Threads

  1. Thread Ownership Problem
    By tntcoda in forum Qt Programming
    Replies: 1
    Last Post: 9th June 2009, 00:18
  2. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  3. Replies: 10
    Last Post: 20th March 2007, 22:19
  4. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 00:49

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.