Results 1 to 4 of 4

Thread: QThread set scheduling policy

  1. #1
    Join Date
    Jul 2010
    Posts
    37
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default QThread set scheduling policy

    Is it possible to set scheduling policy in Qthread ?
    Im using ubuntu, and I'm confident that qthreads are implemented using pthreads, but I don't know how to acces pthreads attribs for advanced tuning like setting scheduling policy.

    With posix classes I would use:
    Qt Code:
    1. #include <pthread.h>
    2. pthread_attr_t attrib;
    3. pthread_attr_init(&attrib);
    4. int ret = pthread_attr_setschedpolicy(&attrib, SCHED_RR);
    To copy to clipboard, switch view to plain text mode 

    but I don't figure out how to do this with Qthreads.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QThread set scheduling policy

    You will have to patch Qt, more precisely QThread::start() in corelib/thread/qthread_unix.cpp

    Cheers,
    _

  3. #3
    Join Date
    Jul 2010
    Posts
    37
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QThread set scheduling policy

    thanks for the advice, although I'm in doubt about this: I wonder how to expose in QThread attrib struct. The regular way should be to provide an accessor to internal data. If I modify the start() call, I I have to pass as argument the attribs struct address, and inside the method start() i should manipulate the scheduler, that isn't correct from the encapsulation point of view. Isn't it?
    So, after this brainstorming, I can reformulate my question to you: how to modify qthread sources (POSIX part) in order to encapsulate the scheduling policies?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QThread set scheduling policy

    Hmm, you could add another enum.

    Cheers,
    _

Similar Threads

  1. Replies: 1
    Last Post: 4th October 2012, 14:49
  2. Scheduling library
    By pkj in forum Qt Programming
    Replies: 2
    Last Post: 24th June 2011, 18:29
  3. Scheduling
    By stevey in forum Qt Programming
    Replies: 2
    Last Post: 18th June 2011, 06:31
  4. Scheduling long terms events in Qt
    By KanadaKid in forum Qt Programming
    Replies: 2
    Last Post: 12th October 2010, 05:49
  5. Cron or Quartz-like event scheduling?
    By davelowndes in forum Qt Programming
    Replies: 3
    Last Post: 15th August 2010, 22:22

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.