I'm working on a project in C that requires threads running on separate CPUs than the initial process. I am using the pthread library to create these threads. I use sched_setaffinity to pin the main process to a cpu. Can I do the same for each thread to pin them to separate CPUs?
I am also pinning the memory of the main process. Will a call to mlockall(MCL_CURRENT|MCL_FUTURE) before creating pthreads pin all of the memory used by the pthreads as well or would I need to call it again within each pthread?
Thanks in advance.