Migrating a running process/thread to different core

寵の児 提交于 2019-12-12 02:26:16

问题


Is there any way to migrate a currently running process to a different cpu core by triggering the migration from another process.

Here is what i am trying to do in more detail. I am working on a heterogeneous processor system. I have a multi-threaded application which runs on the system. I want to migrate one of the thread to different cores (with different capabilities) whenever my manager process decides.

Can my manager process trigger the thread migration for the particular tid of the target application pid? If so, can it be done instantaneously i.e the running thread be immediately migrated to another core (say from core 0 to core 1) upon triggered by my manager process?


回答1:


I guess this should be possible (if you are using the POSIX threads API) using pthread_setaffinity_np(3):

The pthread_setaffinity_np() function sets the CPU affinity mask of the thread thread to the CPU set pointed to by cpuset. If the call is successful, and the thread is not currently running on one of the CPUs in cpuset, then it is migrated to one of those CPUs.



来源:https://stackoverflow.com/questions/35584582/migrating-a-running-process-thread-to-different-core

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!