lib
houxiao
2017-07-20 72481c0ede11920945d886ff9ad4be4b266863a3
VisitFace/RtspNativeCodec/app/src/main/cpp/cpu_sched_test.cpp
@@ -8,15 +8,22 @@
#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)
    {
        fprintf(stderr, "warning: could not get CPU affinity/n");
    }
   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)
@@ -27,5 +34,12 @@
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);
}