android cpu affinity

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了android cpu affinity相关的知识,希望对你有一定的参考价值。

暂时无法获取当前线程运行在哪个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);
}

  

以上是关于android cpu affinity的主要内容,如果未能解决你的问题,请参考以下文章

nginx优化CPU配置worker_cpu_affinity

nginx worker_cpu_affinity使用方法

CPU affinity 亲和力

nginx的 CPU參数worker_processes和worker_cpu_affinity使用说明

python 绑定进程在某个cpu上执行 affinity

蚂蚁集团 CeresDB 团队 | Rust CPU Affinity 初探