Do you have a question? Post it now! No Registration Necessary
Subject
- Posted on
Set Processor Affinity for x86
- 04-24-2013
- ghosh.subhasish
April 24, 2013, 8:57 am

Hi,
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
code.
There should be a general way to do this. Can someone please suggest one ?
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
code.
There should be a general way to do this. Can someone please suggest one ?

Re: Set Processor Affinity for x86

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:

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!!

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
- » Allwinner releases A31 quad core Linux kernel source code
- — Next thread in » Embedded Linux
-
- » Linaro developer summarizes use of assembler in ARM
- — Previous thread in » Embedded Linux
-
- » Crosscompiling for ARM: reloc type R_ARM_ABS32 is not supported for PIC - ...
- — Newest thread in » Embedded Linux
-
- » Replacement for 741
- — The site's Newest Thread. Posted in » Electronics Design
-