From d475c7ab0b4bd6781c6f312b153a4f5bc780d57a Mon Sep 17 00:00:00 2001 From: chenke <chenke@454eff88-639b-444f-9e54-f578c98de674> Date: 星期四, 27 七月 2017 09:17:59 +0800 Subject: [PATCH] 重命名MitiTrd为MultiTrd --- VisitFace/RtspNativeCodec/app/src/main/cpp/cpu_sched_test.cpp | 36 +++++++++++++++++++++++++++++++----- 1 files changed, 31 insertions(+), 5 deletions(-) diff --git a/VisitFace/RtspNativeCodec/app/src/main/cpp/cpu_sched_test.cpp b/VisitFace/RtspNativeCodec/app/src/main/cpp/cpu_sched_test.cpp index 164c964..5568ac2 100644 --- a/VisitFace/RtspNativeCodec/app/src/main/cpp/cpu_sched_test.cpp +++ b/VisitFace/RtspNativeCodec/app/src/main/cpp/cpu_sched_test.cpp @@ -8,9 +8,11 @@ #include<sys/sysinfo.h> #include<unistd.h> -// setup the cpu set of this program to run on -void set_cpu(int id) +// setup the cpu set of this program (task) to run on +void set_task_cpu(int id) { + int num = sysconf(_SC_NPROCESSORS_CONF); + cpu_set_t mask; CPU_ZERO(&mask); if (sched_getaffinity(0, sizeof(mask), &mask) == -1) @@ -18,14 +20,38 @@ fprintf(stderr, "warning: could not get CPU affinity/n"); } - CPU_SET(id, &mask); + for(int i= 0; i< num; i++) + { + LOG_ERROR << "cpu " << i <<": " << CPU_ISSET(i, &mask) <<LOG_ENDL; + } + + //CPU_CLR(0x0000, &mask); + //CPU_CLR(0x0001, &mask); + //CPU_CLR(0x0002, &mask); + //CPU_CLR(0x0003, &mask); + //CPU_CLR(0x0004, &mask); + //CPU_CLR(0x0005, &mask); + + for(int i= 0; i< num; i++) + { + LOG_ERROR << "cpu " << i <<": " << CPU_ISSET(i, &mask) <<LOG_ENDL; + } + + //CPU_SET(id, &mask); if (sched_setaffinity(0, sizeof(mask), &mask) == -1) { - fprintf(stderr, "warning: could not set CPU affinity/n"); + LOG_ERROR << "warning: could not set CPU affinity" << LOG_ENDL; } } void cpu_sched() { -//set_cpu(0x0003); + //set_task_cpu(0x0003); +} + +void pthread_cpu_sched(const pthread_attr_t *attr) +{ + cpu_set_t mask; + CPU_ZERO(&mask); + } -- Gitblit v1.8.0