Allow percentages for callbackParallelThreads count
This commit is contained in:
1 parent
e66bb87909
commit
fe39a007d8
3 files changed
+42
-3
No files matched your search
@@ -199,7 +199,10 @@ DBCORE_API void callbackQueueShow(const int reset);
|
||||
* Calling with count<0 computes the count based on the number of CPU cores
|
||||
* currently available to the calling thread,
|
||||
* eg. Passing -2 on an 8 core system will start 6 worker threads.
|
||||
* In all cases, at least one worker thread will always run.
|
||||
* The iocsh wrapper also accepts positive or negative percentages for count,
|
||||
* which allows to refer to a fraction of the currently available CPU cores,
|
||||
* always rounding the number of created threads down.
|
||||
* In any case, at least one worker thread will always run.
|
||||
*
|
||||
* An empty prio name or the special value "*" will modify all priorities.
|
||||
* Otherwise, only the named priority is modified.
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
#define EPICS_PRIVATE_API
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "iocsh.h"
|
||||
|
||||
#include "callback.h"
|
||||
@@ -27,6 +29,9 @@
|
||||
#include "dbState.h"
|
||||
#include "db_test.h"
|
||||
#include "dbTest.h"
|
||||
#include "epicsStdlib.h"
|
||||
#include "epicsStdio.h"
|
||||
#include "errlog.h"
|
||||
|
||||
DBCORE_API extern int callbackParallelThreadsDefault;
|
||||
|
||||
@@ -503,7 +508,7 @@ static void callbackQueueShowCallFunc(const iocshArgBuf *args)
|
||||
}
|
||||
|
||||
/* callbackParallelThreads */
|
||||
static const iocshArg callbackParallelThreadsArg0 = { "no of threads", iocshArgInt};
|
||||
static const iocshArg callbackParallelThreadsArg0 = { "no of threads", iocshArgString};
|
||||
static const iocshArg callbackParallelThreadsArg1 = { "priority", iocshArgString};
|
||||
static const iocshArg * const callbackParallelThreadsArgs[2] =
|
||||
{&callbackParallelThreadsArg0,&callbackParallelThreadsArg1};
|
||||
@@ -513,7 +518,25 @@ static const iocshFuncDef callbackParallelThreadsFuncDef = {"callbackParallelThr
|
||||
"or one of LOW, MEDIUM, or HIGH.\n"};
|
||||
static void callbackParallelThreadsCallFunc(const iocshArgBuf *args)
|
||||
{
|
||||
iocshSetError(callbackParallelThreads(args[0].ival, args[1].sval));
|
||||
epicsInt32 num = 0;
|
||||
if (args[0].sval) {
|
||||
char* end;
|
||||
long status = epicsParseInt32(args[0].sval, &num, 10, &end);
|
||||
if (status || (end[0] && strcmp(end, "%") != 0))
|
||||
{
|
||||
fprintf(epicsGetStderr(),
|
||||
ANSI_RED("Invalid integer '%s'.\n"), args[0].sval);
|
||||
iocshSetError(-1);
|
||||
return;
|
||||
}
|
||||
if (end[0] == '%') {
|
||||
/* round down, min 1 */
|
||||
if (num < 0) num += 100;
|
||||
if (num > 0) num = num * epicsThreadGetCPUs() / 100;
|
||||
if (num <= 0) num = 1;
|
||||
}
|
||||
}
|
||||
iocshSetError(callbackParallelThreads(num, args[1].sval));
|
||||
}
|
||||
|
||||
/* dbStateCreate */
|
||||
|
||||
Reference in new issue
Block a user