I have a Raspberry Pi 4, running the latest Raspberry Pi OS version. I have a C++ program running on the Raspberry Pi and i want to distribute the execution of this program on cores 1+2+3, while Raspberry Pi OS runs on core 0.
Down below is a picture of the
As you can see, my program is relatively CPU intensive, which is why I want to distribute the execution of the program on core 1+2+3 (core 2+3+4 on the picture above). Core 0 (core 1 on the picture above) runs Raspberry Pi OS. Right now, the execution of my C++ program is only happening on core 2, and I don't know why...
Below is the
[Unit] Description=Automatically start software After=graphical.target [Service] ExecStart=sudo ./path/to/program Nice=-20 LimitNice=-20 CPUAffinity=1 2 3 Restart=always [Install] WantedBy=graphical.target
The program is set to highest priority (
nice=-20) and i'm using
CPUAffinity=1 2 3 to let core 1+2+3 work on the program.
Below i the
console=serial0,115200 console=tty1 root=PARTUUID=97f8b39e-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles isolcpus=1,2,3
Here I isolate CPU core 1+2+3.
Below is a response when i run the
pid 651's current affinity list: 1-3
The affinity list is correct = core 1-3.
My problem: When running the htop command, the program is still only executed on core 1 (core 2 in htop). How do I distribute the execution of the program so it is run on core 1+2+3?
If i run the exact same program, with the same setup in the
systemd startup-service and
cmdline.txt files, but on a
dietPi OS, the workload of the program is distributed among core 1+2+3, where core 0 runs the dietPi OS:
Here, the workload per core is ~30%, and in Raspberry Pi OS it is ~90% on core 1... (core 2 in the first htop picture).