View topic - cpu management in hyperthreading

cpu management in hyperthreading

anything that doesn't fit to other groups.

cpu management in hyperthreading

Postby nvenuti » Wed Feb 11, 2004 12:52 pm

I work with a single processor with hyperthreading activated
I have 2 questions :

1) I want to launch a thread on the cpu 2 with maximum 63 priority (in order to get the same performance than I have on a single processor without any OS). Most of the time my thread is automatically launch on cpu2, but because I got some freezes, I suspect that sometime my thread is launched on cpu1. I want to force it on cpu 2 (or on the cpu that does not run the OS scheduler).

Processor affinity mask seems not to be in the thread attributes, which command should I use to launch the thread on the right cpu ?

2) With hyperthreading (assuming there is not two real processors), will my cpu2 thread will have the priority of use on the sharing of the processor internal ressources (in concurrence with other threads of cpu1). Should I look to the intel documentation (in the case the processor has its own processor ressource sheduling), or does the Neutrino can answer to the question ? I guess that cpu1 may have the internal ressource priority, is that right ?, in this case how could I cleanly swap the processors to set my thread on cpu1 ?

Thanks for your help

Nicolas
nvenuti
Active Member
 
Posts: 15
Joined: Tue Jan 27, 2004 3:41 pm

Postby xtang » Wed Feb 11, 2004 2:22 pm

1) The function "ThreadCtl(_NTO_TCTL_RUNMASK, mask)" allow you "bind" the calling thread to a
specific cpu (set).

2) Not sure what you are asking for. Hyperthreading on Neutrino is just operate the same
as a SMP machine. The fact it is "hypertheading", could affect to some scheduling decision,
but I believe from the discussion I've seen, the schedule decision is highly depends on
whatis the thread doing. So, there isn't a "best for all case" thing yet.
xtang
QNX Master
 
Posts: 313
Joined: Thu Jul 18, 2002 5:01 pm

Postby nvenuti » Wed Feb 11, 2004 3:03 pm

1) When the thread is launched it may be "randomly" run to a cpu or another, what actually do ThreadCtl(_NTO_TCTL_RUNMASK, TWO) if the calling thread is on cpu ONE, is it moved to cpu TWO at the next schedule ? Is there any way to prepare the thread to go on the desire cpu before creating it ?

2) Hyperthreading simulate roughly smp, but in fact the cpu internal resources are shared. My question is : will a thread with higher priority have priority over the internal resources of the unique cpu, or does it depends of something else ?
nvenuti
Active Member
 
Posts: 15
Joined: Tue Jan 27, 2004 3:41 pm

Postby cdm » Wed Feb 11, 2004 5:05 pm

The rule on SMP is that the highest priority thread that is ready to run will be running. Not the highest 2 (or more), just the highest. Neutrino does a very good job trying to assure that the threads don't migrate between CPUs unless the cost isn't going to be noticeable anyways. On a HT machine there actually isn't much cost moving between the two virtual CPUs so ti doesn't really matter.

Why exactly do you want to lock a thread to the CPU? That isn't going to allow you do take as much advantage of having the virtualized CPU.
cdm
QNX Master
 
Posts: 789
Joined: Fri Jul 05, 2002 9:38 am

Postby nvenuti » Wed Feb 11, 2004 6:10 pm

I agree that Neutrino make a very good job, I just invetigate to know how to be optimal

I have two thread : one for intensive computation and IO with a 15 microsec computation loop and a real time reactivity constraint (that used to be just ok with 100% cpu ) and one for human interface and communication.

My computation code was running without any OS support and used 100% of the cpu. I want to use QNX to get new features (human interface and network communication) but keeping the previous performance. To succeed in porting the code to QNX I need to be as closest as possible of my previous developpement. That is the reason.

Until now my port is not to bad but I guess it could be better by mastering cpu allocation, (even logical for now) but which will become physical in dual processor platform.

Do you have any answer to my previous questions ?
nvenuti
Active Member
 
Posts: 15
Joined: Tue Jan 27, 2004 3:41 pm

Postby xtang » Wed Feb 11, 2004 9:11 pm

1) it's a runmask. by default, the mask is like 0xffffffff, so the thread could go every CPU.
if you set it to 0x00000002, then the calling thread could only run on CPU 2.

2) I am not the expert but I *think* those "internal resources" you are talking about, is
somehow transparent to the OS. At least Neutrino only treat it AS IF this is a 2 CPU
SMP.
xtang
QNX Master
 
Posts: 313
Joined: Thu Jul 18, 2002 5:01 pm

Postby nvenuti » Wed Feb 11, 2004 9:50 pm

2) Ok

1) When I disable interrupt on cpu2, the computer hangs !
Why and how to cure that ? I guess that some part of Neutrino also execute on cpu2 even when I set the maximum priority. Is that normal ? Is it because the inter(logical)processor interrupts are also disabled ? How can I avoid that ? Is it the same on a real bi-processor ?
nvenuti
Active Member
 
Posts: 15
Joined: Tue Jan 27, 2004 3:41 pm

Postby rick » Wed Feb 11, 2004 10:24 pm

I suspect it is the same since I believe only CPU0 handles interrupt dispatching. So the problem is not that the kernel is running on CPU1, but rather that the parts of os always run on CPU0.
rick
QNX Master
 
Posts: 500
Joined: Wed Nov 13, 2002 3:59 am

Postby nvenuti » Wed Feb 11, 2004 10:46 pm

Sorry I don't anderstand
nvenuti
Active Member
 
Posts: 15
Joined: Tue Jan 27, 2004 3:41 pm

Postby cdm » Thu Feb 12, 2004 5:07 am

Why would you want to disable interrupts?
cdm
QNX Master
 
Posts: 789
Joined: Fri Jul 05, 2002 9:38 am

Postby nvenuti » Thu Feb 12, 2004 8:36 am

To make it works like I want :

cpu1 : Neutrino+Human interface+Communication
cpu2 : 100% computation code + I/O && NO OS feature at all

Isn't it posssible to configure like that ? How ?
nvenuti
Active Member
 
Posts: 15
Joined: Tue Jan 27, 2004 3:41 pm

Postby rick » Thu Feb 12, 2004 3:08 pm

Try not running the SMP kernel so QNX is not aware of the second CPU and then start it yourself. It might be doable, but you would have to configure everything yourself and make sure you know how QNX deals with SMP to make it work. There would probably be issues with the APIC, but without spending some time thinking about it, I am not sure whether it would work or not.
rick
QNX Master
 
Posts: 500
Joined: Wed Nov 13, 2002 3:59 am

Postby cdm » Thu Feb 12, 2004 6:04 pm

And it really won't be worth while. If you sent the runmask for the computational thread that is running at 100% CPU to the second CPU nothing else will get scheduledd for that one (as long as you run it at the higest priority in the system).
We actually do this to "simulate" less CPUs when testing other code (run 100% CPU threads on the CPUs we want to disable).
cdm
QNX Master
 
Posts: 789
Joined: Fri Jul 05, 2002 9:38 am


Return to General Programming

Who is online

Users browsing this forum: No registered users and 2 guests