26 #include <epicsStdio.h>
27 #include <epicsEvent.h>
28 #include <epicsThread.h>
29 #include <epicsMath.h>
35 #define epicsExportSharedSymbols
39 static epicsThreadId showThread;
40 static unsigned int showLevel;
43 static const char *policies;
51 static void mcoreThreadShowPrint(epicsThreadOSD *pthreadInfo,
unsigned int level)
54 fprintf(epicsGetStdout(),
" NAME EPICS ID "
55 "LWP ID OSIPRI OSSPRI STATE POLICY CPUSET\n");
57 struct sched_param param;
62 cpuspec[0] =
'?'; cpuspec[1] =
'\0';
63 if (pthreadInfo->tid) {
66 status = pthread_getschedparam(pthreadInfo->tid,
73 priority = param.sched_priority;
77 status = pthread_getaffinity_np(pthreadInfo->tid,
85 fprintf(epicsGetStdout(),
"%16.16s %14p %8lu %3d%8d %8.8s %7.7s %s\n",
88 (
unsigned long)pthreadInfo->lwpId,
89 pthreadInfo->osiPriority, priority,
90 pthreadInfo->isSuspended ?
"SUSPEND" :
"OK",
100 static void mcoreThreadInfo(epicsThreadId
id)
102 mcoreThreadShowPrint(
id, showLevel);
111 static void mcoreThreadInfoOne(epicsThreadId
id)
113 intptr_t u =
id->lwpId;
114 if (
id == showThread || (epicsThreadId) u == showThread) {
125 mcoreThreadShowPrint(0, level);
130 epicsThreadMap(mcoreThreadInfoOne);
139 mcoreThreadShowPrint(0, level);
140 epicsThreadMap(mcoreThreadInfo);
143 static void once(
void *arg)
146 if (!buffer) buffer = (
char *) calloc(
cpuDigits+2,
sizeof(
char));
147 if (!cpuspec) cpuspec = (
char *) calloc(
NO_OF_CPUS + 2,
sizeof(
char));
148 printf(
"MCoreUtils version " VERSION
"\n");
156 static epicsThreadOnceId onceFlag = EPICS_THREAD_ONCE_INIT;
157 epicsThreadOnce(&onceFlag, once, NULL);