1

Suppose an embedded system project where I have a multicore ARM processor (to make it simple assume 2 cores with an unshared cache between the 2 cores). Suppose my system contains a critical task and several non-critical tasks.

Therefore, can I assign the critical task to "core 1" exclusively? And all other to "core 2" exclusively?

If so, how to do and what are the best practices from an implementation point of view [assume I use C]? Should I use a library (if so which one)? An RTOS?

Claudio
  • 10,614
  • 4
  • 31
  • 71
S12000
  • 3,345
  • 12
  • 35
  • 51
  • You should be able to set a core affinity to the thread you are running to make sure your OS places it onto the core you want. https://en.wikipedia.org/wiki/Processor_affinity – Michael Dorgan Feb 15 '18 at 17:38
  • There are id registers and you can certainly isolate code to one core, if id register = core0 then else do something else. BUT...if bare metal, if not baremetal then you need to know how the operating system you are using works and it is a different problem, and/or perhaps that OS doesnt have that feature. so this is too broad of a question as written, but from a technical perspective yes you can do such a thing. – old_timer Feb 15 '18 at 20:35
  • "an unshared cache betweeen the two cores" - you mean, each core has its own private cache? – Vroomfondel Feb 19 '18 at 09:52
  • @Vroomfondel Yeah [at L2 and L3 level] – S12000 Feb 19 '18 at 14:56

2 Answers2

1

Ok, I see that you asked this over in the EE board as well. They gave the same answer I want to give you as well. Use an operating system of some sort to handle thread affinities. If your RTOS or whatever you have does not support this, then look into it and see how it actually handles process/thread scheduling.

Typically, each CPU on a system will be assigned some sort of thread that handles scheduling of tasks. This thread is one of the first things that an OS sets up. Feel free to research some micro kernels out there to see how this is done for your particular processor. You can also find the secret sauce for setting up this thread in the ARM documentation for your particular CPU.

But, I am going out on a limb and assuming this is far, far beyond the scope of any assignment given to you for a project. I would hope that you have some affinity of some sort built into what you were given. Setting up affinity for a known OS is a few seconds task. Setting up affinity on a bare metal system with no OS at all is much more involved.

Original question: https://electronics.stackexchange.com/questions/356225/multicore-arm-how-to-assign-a-critical-task-to-one-dedicated-core#comment854845_356225

Michael Dorgan
  • 12,453
  • 3
  • 31
  • 61
  • thanks a lot michael, actually your answer adds detail compared to the one in EE. I will soon mark the case as solved. – S12000 Feb 15 '18 at 21:52
1

If you don't need real-time functionality, you can do this on a device with a Linux kernel without too much hassle.

See this question here

imbuedHope
  • 508
  • 3
  • 14