Merged Ralph's get-cpus branch.
This commit is contained in:
@@ -6,3 +6,4 @@
|
||||
./include
|
||||
./templates
|
||||
**/O.*
|
||||
./QtC-*
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* National Laboratory.
|
||||
* Copyright (c) 2002 The Regents of the University of California, as
|
||||
* Operator of Los Alamos National Laboratory.
|
||||
* Copyright (c) 2012 ITER Organization
|
||||
* Copyright (c) 2013 ITER Organization.
|
||||
* EPICS BASE is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
@@ -85,6 +85,7 @@ epicsShareFunc void epicsShareAPI epicsThreadSleep(double seconds);
|
||||
epicsShareFunc double epicsShareAPI epicsThreadSleepQuantum(void);
|
||||
epicsShareFunc epicsThreadId epicsShareAPI epicsThreadGetIdSelf(void);
|
||||
epicsShareFunc epicsThreadId epicsShareAPI epicsThreadGetId(const char *name);
|
||||
epicsShareFunc int epicsThreadGetCPUs(void);
|
||||
|
||||
epicsShareFunc const char * epicsShareAPI epicsThreadGetNameSelf(void);
|
||||
|
||||
|
||||
@@ -718,3 +718,12 @@ double epicsThreadSleepQuantum ( void )
|
||||
|
||||
return 1.0 / rtemsTicksPerSecond_double;
|
||||
}
|
||||
|
||||
epicsShareFunc int epicsThreadGetCPUs(void)
|
||||
{
|
||||
#if defined(RTEMS_SMP)
|
||||
return rtems_smp_get_number_of_processors();
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1101,6 +1101,18 @@ epicsShareFunc void * epicsShareAPI epicsThreadPrivateGet ( epicsThreadPrivateId
|
||||
return ( void * ) TlsGetValue ( pPvt->key );
|
||||
}
|
||||
|
||||
/*
|
||||
* epicsThreadGetCPUs ()
|
||||
*/
|
||||
epicsShareFunc int epicsThreadGetCPUs ( void )
|
||||
{
|
||||
SYSTEM_INFO sysinfo;
|
||||
GetSystemInfo(&sysinfo);
|
||||
if (sysinfo.dwNumberOfProcessors > 0)
|
||||
return sysinfo.dwNumberOfProcessors;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef TEST_CODES
|
||||
void testPriorityMapping ()
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* National Laboratory.
|
||||
* Copyright (c) 2002 The Regents of the University of California, as
|
||||
* Operator of Los Alamos National Laboratory.
|
||||
* Copyright (c) 2012 ITER Organization
|
||||
* Copyright (c) 2013 ITER Organization.
|
||||
* EPICS BASE is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
@@ -873,3 +873,18 @@ epicsShareFunc double epicsShareAPI epicsThreadSleepQuantum ()
|
||||
return 1.0 / hz;
|
||||
}
|
||||
|
||||
epicsShareFunc int epicsThreadGetCPUs(void)
|
||||
{
|
||||
long ret;
|
||||
#ifdef _SC_NPROCESSORS_ONLN
|
||||
ret = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
if (ret > 0)
|
||||
return ret;
|
||||
#endif
|
||||
#ifdef _SC_NPROCESSORS_CONF
|
||||
ret = sysconf(_SC_NPROCESSORS_CONF);
|
||||
if (ret > 0)
|
||||
return ret;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -447,3 +447,8 @@ double epicsThreadSleepQuantum ()
|
||||
double HZ = sysClkRateGet ();
|
||||
return 1.0 / HZ;
|
||||
}
|
||||
|
||||
epicsShareFunc int epicsThreadGetCPUs(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,11 @@ static void thread(void *arg)
|
||||
|
||||
MAIN(epicsThreadTest)
|
||||
{
|
||||
testPlan(8);
|
||||
testPlan(9);
|
||||
|
||||
unsigned int ncpus = epicsThreadGetCPUs();
|
||||
testDiag("System has %u CPUs", ncpus);
|
||||
testOk1(ncpus > 0);
|
||||
|
||||
const int ntasks = 3;
|
||||
myThread *myThreads[ntasks];
|
||||
|
||||
Reference in New Issue
Block a user