Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Set Processor Affinity for x86

21 views
Skip to first unread message

ghosh.s...@gmail.com

unread,
Apr 24, 2013, 4:57:52 AM4/24/13
to
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 ?

Przemek Klosowski

unread,
Apr 24, 2013, 10:08:02 PM4/24/13
to
On Wed, 24 Apr 2013 01:57:52 -0700, ghosh.subhasish wrote:

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


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.

ghosh.s...@gmail.com

unread,
Apr 25, 2013, 12:12:25 PM4/25/13
to
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!!
0 new messages