Hi,
I want to start a project with the Jetson Orin Nano. I want to program in C++. In my project I would like to have full control of the 6 CPU cores. I want to be able to specify what exactly will run on each core.
Is that possible?
Or is it like Windows that you do not have control about that?
It depends on what your software is doing. Understand that each core receives its work after an “interrupt” (IRQ). The IRQ and scheduler work together to decide what the core is going to do and when.
There are both hardware interrupts (hardware IRQ) and software interrupts (software IRQ). A hardware IRQ depends on a wire physically telling the core that some physical device on a bus wants servicing (example: A NIC might receive traffic, which results in an IRQ over a wire to the core to inform the CPU/scheduler about the need). A software IRQ is usually associated with a timer (and normally the scheduler considers software tasks in a queue at a 1000 Hz refresh rate).
A hardware driver might be triggered from a hardware IRQ, but then split off some of the work into a software IRQ, e.g., perhaps a network device copies data after a hardware IRQ, but could possibly offload a checksum on that data to a different driver which is using a software IRQ. Good hardware drivers lock up the CPU for the least time possible since many hardware IRQs need to be “atomic” (interrupting something like a hard disk in the middle of writing data could be a "bad idea"™). By splitting mandatory hard atomic time from “soft” issues of timing the system can be more responsive. Multitasking is smoother by doing that.
The topic of forcing software to run on a single core is “affinity”. If a process is capable of being assigned to a specific core (and most software can be; many hardware IRQs cannot be on a Jetson since most of the wiring is to CPU0), then the scheduler will honor affinity.
The “taskset” command is one way to assign affinity. On an Ubuntu host PC check out “man taskset”. See also:
I don’t know how many cores a Nano has, but likely hardware IRQs route to CPU0. On any Linux system you can look at which process goes to which core via its hardware IRQ, and is show in “/proc/interrupts”. A PC tends to have hardware to distribute hardware IRQs to any core, but you won’t see this for most hardware on a Jetson.
As an extension to the very comprehensive answer of @lInuxdev, for when you’ll have digested all of that, or for anyone coming here with the same question, it may be worth mentioning that cores may be used by scheduler if known as available at linux kernel boot time.
One way to have a core not to be used by Linux kernel scheduler would be using isolcpus=1,2 on linux kernel boot args for having nothing else running on cores 1 and 2 than what you launch with taskset for them. I wouldn’t advise disabling core 0.