Merged scan-rate protection changes from 3.14 branch, to revno 12693
This commit is contained in:
@@ -13,14 +13,25 @@
|
||||
|
||||
|
||||
<h2 align="center">Changes made on the 3.15 branch since 3.15.5</h2>
|
||||
|
||||
<!-- Insert new items immediately below here ... -->
|
||||
|
||||
|
||||
<h2 align="center">Changes from the 3.14 branch since 3.15.5</h2>
|
||||
|
||||
<!-- Insert inherited items immediately below here ... -->
|
||||
|
||||
<h3>Checking Periodic Scan Rates</h3>
|
||||
|
||||
<h2 align="center">Changes between 3.15.4 and 3.15.5</h2>
|
||||
<p>Code has been added to the IOC startup to better protect it against bad
|
||||
periodic scan rates, including against locales where <q><tt>.</tt></q> is not
|
||||
accepted as a decimal separator character. If the scan period in a menuScan
|
||||
choice string cannot be parsed, the associated periodic scan thread will no
|
||||
longer be started by the IOC and a warning message will be displayed at iocInit
|
||||
time. The <tt>scanppl</tt> command will also flag the faulty menuScan value.</p>
|
||||
|
||||
|
||||
<h2 align="center">Changes made between 3.15.4 and 3.15.5</h2>
|
||||
|
||||
<h3>dbStatic Library Speedup and Cleanup</h3>
|
||||
|
||||
|
||||
@@ -161,8 +161,11 @@ void scanStop(void)
|
||||
interruptAccept = FALSE;
|
||||
|
||||
for (i = 0; i < nPeriodic; i++) {
|
||||
papPeriodic[i]->scanCtl = ctlExit;
|
||||
epicsEventSignal(papPeriodic[i]->loopEvent);
|
||||
periodic_scan_list *ppsl = papPeriodic[i];
|
||||
|
||||
if (!ppsl) continue;
|
||||
ppsl->scanCtl = ctlExit;
|
||||
epicsEventSignal(ppsl->loopEvent);
|
||||
epicsEventWait(startStopEvent);
|
||||
}
|
||||
|
||||
@@ -207,16 +210,24 @@ void scanRun(void)
|
||||
interruptAccept = TRUE;
|
||||
scanCtl = ctlRun;
|
||||
|
||||
for (i = 0; i < nPeriodic; i++)
|
||||
papPeriodic[i]->scanCtl = ctlRun;
|
||||
for (i = 0; i < nPeriodic; i++) {
|
||||
periodic_scan_list *ppsl = papPeriodic[i];
|
||||
|
||||
if (!ppsl) continue;
|
||||
ppsl->scanCtl = ctlRun;
|
||||
}
|
||||
}
|
||||
|
||||
void scanPause(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = nPeriodic - 1; i >= 0; --i)
|
||||
papPeriodic[i]->scanCtl = ctlPause;
|
||||
for (i = nPeriodic - 1; i >= 0; --i) {
|
||||
periodic_scan_list *ppsl = papPeriodic[i];
|
||||
|
||||
if (!ppsl) continue;
|
||||
ppsl->scanCtl = ctlPause;
|
||||
}
|
||||
|
||||
scanCtl = ctlPause;
|
||||
interruptAccept = FALSE;
|
||||
@@ -288,9 +299,11 @@ void scanAdd(struct dbCommon *precord)
|
||||
}
|
||||
addToList(precord, &piosh->iosl[prio].scan_list);
|
||||
} else if (scan >= SCAN_1ST_PERIODIC) {
|
||||
addToList(precord, &papPeriodic[scan - SCAN_1ST_PERIODIC]->scan_list);
|
||||
periodic_scan_list *ppsl = papPeriodic[scan - SCAN_1ST_PERIODIC];
|
||||
|
||||
if (ppsl)
|
||||
addToList(precord, &ppsl->scan_list);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void scanDelete(struct dbCommon *precord)
|
||||
@@ -354,28 +367,48 @@ void scanDelete(struct dbCommon *precord)
|
||||
}
|
||||
deleteFromList(precord, &piosh->iosl[prio].scan_list);
|
||||
} else if (scan >= SCAN_1ST_PERIODIC) {
|
||||
deleteFromList(precord, &papPeriodic[scan - SCAN_1ST_PERIODIC]->scan_list);
|
||||
periodic_scan_list *ppsl = papPeriodic[scan - SCAN_1ST_PERIODIC];
|
||||
|
||||
if (ppsl)
|
||||
deleteFromList(precord, &ppsl->scan_list);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
double scanPeriod(int scan) {
|
||||
periodic_scan_list *ppsl;
|
||||
|
||||
scan -= SCAN_1ST_PERIODIC;
|
||||
if (scan < 0 || scan >= nPeriodic)
|
||||
return 0.0;
|
||||
return papPeriodic[scan]->period;
|
||||
ppsl = papPeriodic[scan];
|
||||
return ppsl ? ppsl->period : 0.0;
|
||||
}
|
||||
|
||||
int scanppl(double period) /* print periodic list */
|
||||
|
||||
int scanppl(double period) /* print periodic scan list(s) */
|
||||
{
|
||||
periodic_scan_list *ppsl;
|
||||
dbMenu *pmenu = dbFindMenu(pdbbase, "menuScan");
|
||||
char message[80];
|
||||
int i;
|
||||
|
||||
if (!pmenu || !papPeriodic) {
|
||||
printf("scanppl: dbScan subsystem not initialized\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < nPeriodic; i++) {
|
||||
ppsl = papPeriodic[i];
|
||||
if (ppsl == NULL) continue;
|
||||
if (period > 0.0 && (fabs(period - ppsl->period) >.05)) continue;
|
||||
periodic_scan_list *ppsl = papPeriodic[i];
|
||||
|
||||
if (!ppsl) {
|
||||
const char *choice = pmenu->papChoiceValue[i + SCAN_1ST_PERIODIC];
|
||||
|
||||
printf("Periodic scan list for SCAN = '%s' not initialized\n",
|
||||
choice);
|
||||
continue;
|
||||
}
|
||||
if (period > 0.0 &&
|
||||
(fabs(period - ppsl->period) > 0.05))
|
||||
continue;
|
||||
|
||||
sprintf(message, "Records with SCAN = '%s' (%lu over-runs):",
|
||||
ppsl->name, ppsl->overruns);
|
||||
printList(&ppsl->scan_list, message);
|
||||
@@ -694,7 +727,7 @@ static void periodicTask(void *arg)
|
||||
if (++overruns >= 10 &&
|
||||
epicsTimeDiffInSeconds(&now, &reported) > report_delay) {
|
||||
errlogPrintf("\ndbScan warning from '%s' scan thread:\n"
|
||||
"\tScan processing averages %.2f seconds (%.2f .. %.2f).\n"
|
||||
"\tScan processing averages %.3f seconds (%.3f .. %.3f).\n"
|
||||
"\tOver-runs have now happened %u times in a row.\n"
|
||||
"\tTo fix this, move some records to a slower scan rate.\n",
|
||||
ppsl->name, ppsl->period + overtime / overruns,
|
||||
@@ -741,12 +774,8 @@ static void initPeriodic(void)
|
||||
char *unit;
|
||||
int status = epicsParseDouble(choice, &number, &unit);
|
||||
|
||||
ppsl->scan_list.lock = epicsMutexMustCreate();
|
||||
ellInit(&ppsl->scan_list.list);
|
||||
ppsl->name = choice;
|
||||
if (status || number == 0) {
|
||||
if (status || number <= 0) {
|
||||
errlogPrintf("initPeriodic: Bad menuScan choice '%s'\n", choice);
|
||||
ppsl->period = i;
|
||||
}
|
||||
else if (!*unit ||
|
||||
!epicsStrCaseCmp(unit, "second") ||
|
||||
@@ -767,16 +796,24 @@ static void initPeriodic(void)
|
||||
}
|
||||
else {
|
||||
errlogPrintf("initPeriodic: Bad menuScan choice '%s'\n", choice);
|
||||
ppsl->period = i;
|
||||
}
|
||||
if (ppsl->period == 0) {
|
||||
free(ppsl);
|
||||
continue;
|
||||
}
|
||||
|
||||
ppsl->scan_list.lock = epicsMutexMustCreate();
|
||||
ellInit(&ppsl->scan_list.list);
|
||||
ppsl->name = choice;
|
||||
ppsl->scanCtl = ctlPause;
|
||||
ppsl->loopEvent = epicsEventMustCreate(epicsEventEmpty);
|
||||
|
||||
number = ppsl->period / quantum;
|
||||
if ((ppsl->period < 2 * quantum) ||
|
||||
(number / floor(number) > 1.1)) {
|
||||
errlogPrintf("initPeriodic: Scan rate '%s' is not achievable.\n",
|
||||
choice);
|
||||
}
|
||||
ppsl->scanCtl = ctlPause;
|
||||
ppsl->loopEvent = epicsEventMustCreate(epicsEventEmpty);
|
||||
|
||||
papPeriodic[i] = ppsl;
|
||||
}
|
||||
@@ -788,6 +825,8 @@ static void deletePeriodic(void)
|
||||
|
||||
for (i = 0; i < nPeriodic; i++) {
|
||||
periodic_scan_list *ppsl = papPeriodic[i];
|
||||
|
||||
if (!ppsl) continue;
|
||||
ellFree(&ppsl->scan_list.list);
|
||||
epicsEventDestroy(ppsl->loopEvent);
|
||||
epicsMutexDestroy(ppsl->scan_list.lock);
|
||||
@@ -800,10 +839,11 @@ static void deletePeriodic(void)
|
||||
|
||||
static void spawnPeriodic(int ind)
|
||||
{
|
||||
periodic_scan_list *ppsl;
|
||||
periodic_scan_list *ppsl = papPeriodic[ind];
|
||||
char taskName[20];
|
||||
|
||||
ppsl = papPeriodic[ind];
|
||||
if (!ppsl) return;
|
||||
|
||||
sprintf(taskName, "scan-%g", ppsl->period);
|
||||
periodicTaskId[ind] = epicsThreadCreate(
|
||||
taskName, epicsThreadPriorityScanLow + ind,
|
||||
|
||||
Reference in New Issue
Block a user