mirror of
https://gitee.com/openharmony/third_party_benchmark
synced 2024-11-23 07:20:12 +00:00
f9e826db52
Signed-off-by: CrazyRong <zzr189911@163.com>
17 lines
389 B
C++
17 lines
389 B
C++
#include <pthread.h>
|
|
int main() {
|
|
cpu_set_t set;
|
|
CPU_ZERO(&set);
|
|
for (int i = 0; i < CPU_SETSIZE; ++i) {
|
|
CPU_SET(i, &set);
|
|
CPU_CLR(i, &set);
|
|
}
|
|
pthread_t self = pthread_self();
|
|
int ret;
|
|
ret = pthread_getaffinity_np(self, sizeof(set), &set);
|
|
if (ret != 0) return ret;
|
|
ret = pthread_setaffinity_np(self, sizeof(set), &set);
|
|
if (ret != 0) return ret;
|
|
return 0;
|
|
}
|