增加 syscall(__NR_sched_setaffinity).
Signed-off-by: rick.chan <chenyang@autoai.com>
This commit is contained in:
parent
73848bd3d1
commit
2cecefab7e
|
@ -261,3 +261,20 @@ this thread 2812323584 is running in processor 1
|
||||||
this thread 2812323584 is running in processor 2
|
this thread 2812323584 is running in processor 2
|
||||||
this thread 2812323584 is running in processor 3
|
this thread 2812323584 is running in processor 3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 4.Android 系统的特殊说明
|
||||||
|
|
||||||
|
Android 系统屏蔽了 pthread_setaffinity_np() 函数,需要通过 syscall(__NR_sched_setaffinity) 替代:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
void set_cur_thread_affinity(int mask) {
|
||||||
|
int err, syscallres;
|
||||||
|
pid_t pid = gettid();
|
||||||
|
syscallres = syscall(__NR_sched_setaffinity, pid, sizeof(mask), &mask);
|
||||||
|
if (syscallres) {
|
||||||
|
err = errno;
|
||||||
|
LOGE("Error in the syscall setaffinity: mask = %d, err=%d",mask,errno);
|
||||||
|
}
|
||||||
|
LOGD("tid = %d has setted affinity success",pid);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in New Issue