Set Processor Affinity for x86

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View

I need to understand how to run a function on a core other than the current.

For example, my main() function could be on core-0, but I want to run a function
on core-1.

There are APIs in Linux like sched_setaffinity();

The platform that I am using does not have any OS or scheduler.

But, when I looked into the code of this function in the Kernel, I see that it
just updates the task_struct.

I need to understand how the dispatcher, dispatches the code on another core.

Initially, my thought was to modify the Instruction Pointer of the other core to
the code section of the function. But, I found that we cannot change the IP from

There should be a general way to do this. Can someone please suggest one ?

Re: Set Processor Affinity for x86
On Wed, 24 Apr 2013 01:57:52 -0700, ghosh.subhasish wrote:

Quoted text here. Click to load it

You are in for a treat. It's easy in Linux because there's a lot if  
infrastructure already present; you have to accomplish equivalent  
preparation yourself. Essentially, different cores are separate CPUs that  
simply look at the same memory; they all execute some code (possibly even  
same code, e.g. if they were all in idle loop or idle wait). If you want  
another CPU to execute some routine you have prepared for it, you just  
have to tell the dispatcher running on that CPU to jump to the memory  
area where you placed your code.

Re: Set Processor Affinity for x86
On Thursday, April 25, 2013 7:38:02 AM UTC+5:30, Przemek Klosowski wrote:
Quoted text here. Click to load it

I do not have a dispatcher. I can write one, but my problem still remains the
same. How will the get the dispatcher to run on every core for the first time ?

Maybe, I can setup a timer which will send interrupt to all cores. I can replace
the handler with the dispatcher code ?, But then, suppose I have 4-cores, then I
am doubtful if I will have 4 handlers, one for each core.

How is this done in General. All OS must go through this!!

Site Timeline