暂时无法获取当前线程运行在哪个CPU上,待调查...
int omask = 0;
int nmask = 0xF0; static void affinity() {
int err; int syscallres = syscall(__NR_sched_getaffinity, gettid(), sizeof(omask), &omask);
if (syscallres) {
err = errno;
LOGE("Error in the syscall getaffinity: omask=%d=0x%x err=%d=0x%x", omask, omask, err, err);
} LOGE("before-get affinity success, tid = %d , mask = ", gettid(), omask);
syscallres = syscall(__NR_sched_setaffinity, gettid(), sizeof(nmask), &nmask);
if (syscallres) {
err = errno;
LOGE("Error in the syscall setaffinity: nmask=%d=0x%x err=%d=0x%x", nmask, nmask, err, err);
} syscallres = syscall(__NR_sched_getaffinity, gettid(), sizeof(omask), &omask);
if (syscallres) {
err = errno;
LOGE("Error in the syscall getaffinity: omask=%d=0x%x err=%d=0x%x", omask, omask, err, err);
} LOGE("after-get affinity success, tid = %d , mask = ", gettid(), omask);
}