I have /cgroup/cpuset/set1. set1 has 2-5,8. I want to bind a process to that cpuset and then pin a thread in that process to, say, core 4. The name of the cpuset and the thread name and the core to which I should bind the thread is in m config file. Are there any C APIs to parse cpuset? What is the correct way to achieve the pinning using C code?
相关问题
- Multiple sockets for clients to connect to
- slurm: use a control node also for computing
- Is shmid returned by shmget() unique across proces
- What is the best way to do a search in a large fil
- glDrawElements only draws half a quad
Take a look at the
pthread_setaffinity_np
andpthread_getaffinity_np
functions.Example:
For more details, see the man page.
Call the following Function and pass whatever core ID you want to pass. Also from wherever you call this function do check its return value to be 1.