How to run code on a specific CPU

How to run code on a specific CPU

Hi all,

I have multi-core processor (Core -2 duo) which has 4 logical processors. I would like to switch processor to run the code. For example,

;Assuming code is running on CPU-0
mov eax, ecx

; I want to switchto CPU-1 (don't know how to go about it)
mov ebx, eax

; Switch back to CPU-0 here
mov ecx, eax

Note: Above is just a sample code. My intentions are to learn how to switch b/w CPU's and to set code affinity to a specific CPU

Help appreciated


3 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

This question might be handled better on the threading forum, but you should specify your OS and more about what you wish to accomplish.

Thanks Tim. I will re-ask this question in threading forum.

I was writing a test driver in Windows OS, and came across KeSetProcessorAffinity function which was forcing the code to run on a specific processor. After the call, the code somehow started running on CPU [0-3]. That made me think what could be logic behind this function call. And that was my original question.

After reading through Intel documentation, I know how interrupt routines can be executed on a dedicated processor (by setting destination bits in IOREDIRECT table - IOAPIC), but I don't know exactly how a running thread can be executed on a specific processor.

Laisser un commentaire

Veuillez ouvrir une session pour ajouter un commentaire. Pas encore membre ? Rejoignez-nous dès aujourd’hui