Could anyone tell me what would occur if I ran
taskset -c 7 ./fred.x
but then inside fred.x
a thread is calling sched_setaffinity
to bind to core 6?
Would that thread get ANY cpu time ever, or will it remain idle indefinitely?
taskset
itself calls sched_setaffinity()
and then execve
to run your command. So this question boils down to "What happens if I call sched_setaffinity()
twice in the same thread?" And the answer is, the second call overrides the first.
So in your specific example, the thread which calls sched_setaffinity()
will indeed be bound to core 6, and it will be runnable.