简体   繁体   中英

Interaction between taskset and sched_setaffinity

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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM