Results 1 to 2 of 2

Thread: QThread affinity

  1. #1
    Join Date
    Feb 2006
    Location
    US
    Posts
    173
    Thanks
    16
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default QThread affinity

    I did a search ... couldn't find this particular question answered.

    How is thread affinity determined for non-Qt objects? What mechanism?

    For example, I have an application that uses legacy code ... leveraging low-level socket library. When I create the non-Qt socket in the run method of the QThread, how does the Qt threading "know" that the socket has affinity with the child thread? Obviously it doesn't block the process on block read ... just wonder how/why?

    Also, are QThreads kernel-level or library threads? It depends upon the OS and what Qt is built upon.

    Thanks,
    Ben

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QThread affinity

    Also, are QThreads kernel-level or library threads? It depends upon the OS and what Qt is built upon.
    For example, on Windows, the _beginthreadex CRT function is used to create a QThread.
    I am not sure if the underlying implementation is based on kernel threads, but it should be, since all modern operating systems do that.

    Anyway, NT and above have a compliance layer for POSIX(therefore pthreads) but it is not documented and I don't think anyone has ever used it.

    How is thread affinity determined for non-Qt objects? What mechanism?

    For example, I have an application that uses legacy code ... leveraging low-level socket library. When I create the non-Qt socket in the run method of the QThread, how does the Qt threading "know" that the socket has affinity with the child thread? Obviously it doesn't block the process on block read ... just wonder how/why?
    It is not determined in any way. The OS kernel takes care of that.
    At the lowest level, the kernel gets the entry point of the code segment for the thread.
    The socket code is part of that code segment. Therefore it is executed in the thread's context.

    Regards
    Last edited by marcel; 29th August 2007 at 19:36.

Similar Threads

  1. QThread exec proplem to stop...
    By patrik08 in forum Qt Programming
    Replies: 29
    Last Post: 21st May 2007, 07:51
  2. Qthread Issue?
    By vishal.chauhan in forum Newbie
    Replies: 3
    Last Post: 29th March 2007, 08:50
  3. QGraphicsScene and QThread
    By tts80 in forum Qt Programming
    Replies: 5
    Last Post: 10th January 2007, 09:32
  4. how to use QHttp inside QThread in Qt3
    By alusuel in forum Qt Programming
    Replies: 3
    Last Post: 14th July 2006, 11:19
  5. Is it possible to create a QThread without inheriting ?
    By probine in forum Qt Programming
    Replies: 6
    Last Post: 23rd March 2006, 22:51

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.