How do I program for multi cores in Qt

Posted on 2011-05-09
Medium Priority
Last Modified: 2012-05-11
I use RHEL 5 and QT 4.6.2. How do I program for multi cores that are available on my system. I would like to specify that thread 1 should always run on core 1 whereas thread 2 should always run on core 2 or something like that. Is this doable in RHEL or do I need a special RTOS?

Question by:rkreddy_kbs
  • 2

Expert Comment

ID: 35723678
There is no way in QT you can do this. May be you can try some other library where you can really acheive this or may be you can write your own C routine which can allow this.

But Qt is not having any api or any thing which can does it unless you dont modify Qt srouce to do it.

Author Comment

ID: 35723762
Any suggestions for such a library - OpenMP ?

Expert Comment

ID: 35724224
I am sorry, I am not aware of any such library,
You know what it is kind of very difficult what you are tryiing to achieve because it is all OS Kernel which does this. this core thing of processor is all based on cycle stealing so only one way i can think to acheive via interrupt or some mechanism where you can come to know that One core is about to be finish thejob and there you can utilize the secod core.

Well this is my best guess what I said above, but I think it is hard to have this thing at application level.

Best of luck for your effort, and do let me know if you find some way of doing this
LVL 12

Accepted Solution

HappyCactus earned 1000 total points
ID: 35727149
You cannot do it by using QT only, because processor affinity is a very low level service provided by the O.S., so it cannot, for now, be provided by a cross platform library.
You can use sched_setaffinity() call.
As you can read from this page, cpu affinity is set on a thread group basis.
So to bound a thread to only one (or a group of) cpu, you must pass the result of getid() as a pid (read the notes on this page).

You can also use sched tools; this article explains how.

Hope that helps.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
Suggested Courses

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question