I'm using posix_spawn function in 1 parent process to call other executable files child processes. I want to dedicate some of those child processes exclusively to a cpu for each (I know I cannot dedicate 4 of them as the kernel and other processes are critical and they should run, but let's assume now for at least 1 or 2 processes).
I ran htop command and I saw that all the 4 cores are being used, but I want to be able to have more control in case I got hundreds of processes so I decide which can run fully.
You can use sched_setaffinity()
system call to assign CPU core for a process. see manpage
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.