16 #include <epicsExport.h>
17 #include <epicsThread.h>
26 static epicsThreadId getThreadIdFor(
const char* thread) {
32 if (!thread)
return 0;
34 ltmp = strtoul(cp, &endp, 0);
36 tid = epicsThreadGetId(cp);
38 printf(
"*** %s is not a valid thread name ***\n", cp);
42 tid = (epicsThreadId) ltmp;
47 static const iocshArg mcoreThreadShowArg0 = {
"thread", iocshArgString};
48 static const iocshArg mcoreThreadShowArg1 = {
"level", iocshArgInt};
49 static const iocshArg *
const mcoreThreadShowArgs[] = {
53 static const iocshFuncDef mcoreThreadShowDef =
54 {
"mcoreThreadShow", 2, mcoreThreadShowArgs};
55 static void mcoreThreadShowCall(
const iocshArgBuf * args) {
57 unsigned int level = args[1].ival;
59 printf(
"Missing argument\nUsage: mcoreThreadShow thread [level]\n");
62 tid = getThreadIdFor(args[0].sval);
69 static const iocshArg mcoreThreadShowAllArg0 = {
"level", iocshArgInt};
70 static const iocshArg *
const mcoreThreadShowAllArgs[] = {
71 &mcoreThreadShowAllArg0,
73 static const iocshFuncDef mcoreThreadShowAllDef =
74 {
"mcoreThreadShowAll", 1, mcoreThreadShowAllArgs};
75 static void mcoreThreadShowAllCall(
const iocshArgBuf * args) {
76 unsigned int level = args[0].ival;
80 static const iocshArg mcoreThreadRuleAddArg0 = {
"name", iocshArgString};
81 static const iocshArg mcoreThreadRuleAddArg1 = {
"policy", iocshArgString};
82 static const iocshArg mcoreThreadRuleAddArg2 = {
"priority", iocshArgString};
83 static const iocshArg mcoreThreadRuleAddArg3 = {
"cpuset", iocshArgString};
84 static const iocshArg mcoreThreadRuleAddArg4 = {
"pattern", iocshArgString};
85 static const iocshArg *
const mcoreThreadRuleAddArgs[] = {
86 &mcoreThreadRuleAddArg0,
87 &mcoreThreadRuleAddArg1,
88 &mcoreThreadRuleAddArg2,
89 &mcoreThreadRuleAddArg3,
90 &mcoreThreadRuleAddArg4,
92 static const iocshFuncDef mcoreThreadRuleAddDef =
93 {
"mcoreThreadRuleAdd", 5, mcoreThreadRuleAddArgs};
94 static void mcoreThreadRuleAddCall(
const iocshArgBuf * args) {
98 if (NULL == args[i].sval) missing |= 1;
101 printf(
"Missing argument\nUsage: mcoreThreadRuleAdd name policy priority cpuset pattern\n");
104 mcoreThreadRuleAdd(args[0].sval, args[1].sval, args[2].sval, args[3].sval, args[4].sval);
107 static const iocshArg mcoreThreadRuleDeleteArg0 = {
"name", iocshArgString};
108 static const iocshArg *
const mcoreThreadRuleDeleteArgs[] = {
109 &mcoreThreadRuleDeleteArg0,
111 static const iocshFuncDef mcoreThreadRuleDeleteDef =
112 {
"mcoreThreadRuleDelete", 1, mcoreThreadRuleDeleteArgs};
113 static void mcoreThreadRuleDeleteCall(
const iocshArgBuf * args) {
114 if (NULL == args[0].sval) {
115 printf(
"Missing argument\nUsage: mcoreThreadRuleDelete name\n");
121 static const iocshFuncDef mcoreThreadRulesShowDef =
122 {
"mcoreThreadRulesShow", 0, NULL};
123 static void mcoreThreadRulesShowCall(
const iocshArgBuf * args) {
127 static const iocshArg mcoreThreadModifyArg0 = {
"thread", iocshArgString};
128 static const iocshArg mcoreThreadModifyArg1 = {
"policy", iocshArgString};
129 static const iocshArg mcoreThreadModifyArg2 = {
"priority", iocshArgString};
130 static const iocshArg mcoreThreadModifyArg3 = {
"cpuset", iocshArgString};
131 static const iocshArg *
const mcoreThreadModifyArgs[] = {
132 &mcoreThreadModifyArg0,
133 &mcoreThreadModifyArg1,
134 &mcoreThreadModifyArg2,
135 &mcoreThreadModifyArg3,
137 static const iocshFuncDef mcoreThreadModifyDef =
138 {
"mcoreThreadModify", 4, mcoreThreadModifyArgs};
139 static void mcoreThreadModifyCall(
const iocshArgBuf * args) {
144 for (i = 0; i < 4; i++) {
145 if (NULL == args[i].sval) missing |= 1;
148 printf(
"Missing argument\nUsage: mcoreThreadModify thread policy priority cpuset\n");
151 tid = getThreadIdFor(args[0].sval);
156 static const iocshFuncDef mcoreMLockDef =
157 {
"mcoreMLock", 0, NULL};
158 static void mcoreMLockCall(
const iocshArgBuf * args) {
162 static const iocshFuncDef mcoreMUnlockDef =
163 {
"mcoreMUnlock", 0, NULL};
164 static void mcoreMUnlockCall(
const iocshArgBuf * args) {
168 static void mcoreRegister(
void)
170 static int firstTime = 1;
171 if(!firstTime)
return;
176 iocshRegister(&mcoreThreadShowDef, mcoreThreadShowCall);
177 iocshRegister(&mcoreThreadShowAllDef, mcoreThreadShowAllCall);
178 iocshRegister(&mcoreThreadRuleAddDef, mcoreThreadRuleAddCall);
179 iocshRegister(&mcoreThreadRuleDeleteDef, mcoreThreadRuleDeleteCall);
180 iocshRegister(&mcoreThreadRulesShowDef, mcoreThreadRulesShowCall);
181 iocshRegister(&mcoreThreadModifyDef, mcoreThreadModifyCall);
182 iocshRegister(&mcoreMLockDef, mcoreMLockCall);
183 iocshRegister(&mcoreMUnlockDef, mcoreMUnlockCall);
186 epicsExportRegistrar(mcoreRegister);