1

From my understanding a real-time process means the process will get the CPU as soon as it needs it. The kernel is responsible for this task with its internal scheduling mechanism.

On the other hand, Process affinity means the process will get a dedicated CPU to itself and it won't be managed by kernel scheduler. So, if I understand correctly, it's even better than being a real-time process. It's like programming for an Arduino but only with a much faster CPU. Also, to my understanding for process affinity we need at least a dual core CPU, and we must leave at least one CPU for the OS itself. So, with the help of process affinity a program that was written for an Arduino can be ported to a Linux board like Raspberry Pi Zero 2 W (which has a quad-core CPU) and would have all the benefits of a microcontroller only with a faster CPU.

Is my understanding correct?

1 Answer 1

0
+100

I think you are mixing two concepts that have different meaning than you have described. They have different usage workflows. It all comes to what you actually need

Real-Time

The real-time, in linux I presume, is designed to provide predictable and deterministic behaviour for any time-sensitive application(s).

In the ordinary linux processes are using scheduler which has different priorities and time-sharing. Those can be influenced, by e.g. nice. The real-time Linux ensures that the time critical tasks gets immediate attention and executes within certain time constrains.

CPU Affinity

Processor affinity actually binds a process to a specific processor(s). That is the reason why it is also called CPU pinning.

Imagine having a machine with 128 processors. Why would you like to pin a process to certain processor? The main reason for cpu affinity is to avoid cache misses, which causes latency issues. With 128 processors that could be a real issue which could slow down the task you would be doing.

Answer

So, with the help of process affinity a program that was written for an Arduino can be ported to a Linux board like Raspberry Pi Zero 2 W (which has a quad-core CPU) and would have all the benefits of a micro-controller only with a faster CPU.

To answer your question processor affinity is for optimizing cache performance, which improves latency, but it does not guarantee any deterministic behaviour to time-critical applications. On the other hand, real-time kernel should guarantee a deterministic bahaviour.

Depends on what kind of application we are talking. If you need to for it to behave in a deterministic way, meaning you will get always answer within a certain time-frame then use real-time linux implementation.

If you need to avoid cache misses you can try CPU affinity.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.