![]() |
![]() ![]()
Experimental Physics and
| ||||||||||||||||
|
After adding two additional scans: 0.01 and 0.005, it seems to me that the EPICS scan loops use delays instead of timers. Is this true? If so, can this be changed easily? If so ... The code that runs in the periodic scan tasks is in src/db/dbScan.c: static void periodicTask(void *arg) { scan_list *psl = (scan_list *)arg; epicsTimeStamp start_time,end_time; double diff; double delay; taskwdInsert(epicsThreadGetIdSelf(), NULL, NULL); epicsTimeGetCurrent(&start_time); while(TRUE) { if (interruptAccept) scanList(psl); epicsTimeGetCurrent(&end_time); diff = epicsTimeDiffInSeconds(&end_time, &start_time); delay = psl->period - diff; delay = (delay <= 0.0) ? .1 : delay; epicsThreadSleep(delay); epicsTimeGetCurrent(&start_time); } } Hmm, I suspect that the magic ".1" number in the delay calculation could probably be reduced to something a little smaller nowadays, but the correct value is likely to be processor-specific. If you have any alternative robust cross-platform suggestions for this code I'd be interested in seeing them. In particular, it must behave sensibly if the scanList() call that processes the records takes longer than a whole scan period to execute - the above delay calculation ensures that the slower scan periods will always get some time to execute even if the faster scans always overrun their periods. This is most important on OSs where threads are scheduled strictly by priority so the slower scans could suffer from CPU starvation. - Andrew -- There is no S in exprexxo.
| ||||||||||||||||
ANJ, 02 Sep 2010 |
![]() · Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing · |