#ifndef KNOB_DEVSUP_H #define KNOB_DEVSUP_H #ifdef __cplusplus extern "C" { #endif #include IOSCANPVT devKnobDeviceStateScan; IOSCANPVT devKnobDeviceInfoScan; IOSCANPVT devKnobDeviceValScan; /* * Note: there are a couple records that need to be modified by both * the user interface (device support) and the driver. Thus these are * handled a little differently: we do not use scanIoRequest because * that requires SCAN=I/O Intr and that would not allow changes from the * user interface. Instead when the driver initiates a change, device support * uses dbScanLock and scanOnce to update and process. See knobUserEpics.h * for more details */ typedef struct { int box; int knob; int index; char parm[25]; int valupdate; /* Flag to not take normal actions * next time a record processes * because we only wanted to update * its value. At this time, only used * for device name PV that also launches * attach functions. */ } knobdevsup_ts; /* IMPORTANT NOTE on avoiding deadlocks in above scenario * * If we're not careful in how we lock data in this situation, we can end up * in a deadlock, in particular when calling the dbScanLock routine. * * Scenario to avoid: * * Driver * --------------------- Devsup CB routine * | 1. locks mutex A | --------------------- * | 2. calls devsup cb |---> | 1. calls dbScanLock | * | routine | | to lock EPICS | * --------------------- | record Z | * --------------------- * * while * * EPICS record Z * ------------------------ * | 1. record proceses | * | 2. calls dbSanLock | * | to lock record Z | * | 3. calls our device | * | support 'write' | * | routine | Driver * | 4. write routine calls|---> ---------------------- * | driver routine to | | 1. locks mutex A | * | update driver data | | (tries and fails) | * ----------------------- ---------------------- * * * How to avoid this: * * Driver code that calls a devsup callback routine (if the latter * locks the record some way, i.e. dbScanLock) must not first * lock mutex A IF standard record processing for that same record * will also try to lock mutex A. */ #ifdef __cplusplus }; #endif #endif /* KNOB_DEVSUP_H guard macro */