Commit 6964d966 authored by nextime's avatar nextime

set don't retrieve the core number at every run

parent e130e243
......@@ -26,26 +26,29 @@ int pthread_create(pthread_t *thread,
{
char *msg;
int ret;
unsigned int ncore=sysconf (_SC_NPROCESSORS_CONF);
unsigned int setcore=NULL;
static unsigned int ncore;
static unsigned int setcore=-1;
cpu_set_t mask; /* Define your cpu_set bit mask. */
CPU_ZERO(&mask); /* Initialize it all to 0, i.e. no CPUs selected. */
msg = getenv("PINTHREAD_CORE");
if (msg!=NULL)
if(setcore == -1)
{
setcore = (unsigned int) strtoul(msg, (char **)NULL, 10);
if(setcore < ncore)
ncore = sysconf (_SC_NPROCESSORS_CONF);
msg = getenv("PINTHREAD_CORE");
if (msg != NULL)
{
CPU_SET(setcore, &mask);
setcore = (unsigned int) strtoul(msg, (char **)NULL, 10);
if(setcore >= ncore)
{
fprintf(stderr, "**PINTHREAD wrong value for PINTHREAD_CORE: %u - using default.\n", setcore);
setcore = sched_getcpu();
}
} else {
fprintf(stderr, "**PINTHREAD wrong value for PINTHREAD_CORE: %u - using default.\n", setcore);
CPU_SET(sched_getcpu(), &mask);
setcore = sched_getcpu();
}
} else {
CPU_SET(setcore, &mask);
}
CPU_SET(setcore, &mask);
if (real_pthread_create == NULL)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment