在Windows上,存在GetProcessAffinityMask API调用,并且还存在一种查找线程关联掩码的迂回方式,如下所示:
Query thread (not process) processor affinity?
有没有办法在Linux中获取此信息?对sched_getcpu()的调用仅返回当前运行该线程的cpu,而不返回其关联掩码 .
在Windows上,存在GetProcessAffinityMask API调用,并且还存在一种查找线程关联掩码的迂回方式,如下所示:
Query thread (not process) processor affinity?
有没有办法在Linux中获取此信息?对sched_getcpu()的调用仅返回当前运行该线程的cpu,而不返回其关联掩码 .
1 回答
sched_setaffinity() & sched_getaffinity() .
pthread_attr_setaffinty_np() & pthread_attr_getaffinity_np() .
pthread_setaffinity_np() & pthread_getaffinity_np() .
_np代表非便携式 .