ringPointerTest in thread

This commit is contained in:
Michael Davidsaver
2022-10-28 12:38:14 -04:00
parent b460c2659e
commit 166267a32f
2 changed files with 25 additions and 7 deletions

View File

@@ -758,6 +758,9 @@ LIBCOM_API void epicsStdCall epicsThreadSetPriority(epicsThreadId pthreadInfo,un
assert(epicsThreadOnceCalled);
assert(pthreadInfo);
if(!pthreadInfo->isEpicsThread) {
/* not allowed to avoid dealing with (potentially) different scheduling
* policies (FIFO vs. RR vs. OTHER vs. ...)
*/
fprintf(stderr,"epicsThreadSetPriority called by non epics thread\n");
return;
}

View File

@@ -240,17 +240,32 @@ static void testPair(int locked)
epicsRingPointerDelete(ring);
}
static
void testInThread(void *raw)
{
epicsEventId stop = raw;
testPair(0);
testPair(1);
epicsEventMustTrigger(stop);
}
MAIN(ringPointerTest)
{
int prio = epicsThreadGetPrioritySelf();
epicsThreadId tid;
epicsThreadOpts opts = EPICS_THREAD_OPTS_INIT;
epicsEventId stop = epicsEventMustCreate(epicsEventEmpty);
testPlan(42);
testSingle();
if (prio)
epicsThreadSetPriority(epicsThreadGetIdSelf(), epicsThreadPriorityScanLow);
testPair(0);
testPair(1);
if (prio)
epicsThreadSetPriority(epicsThreadGetIdSelf(), prio);
/* testPair() needs to run with a priority > 0.
* Start a new thread since main() is a "non-epics"
* thread, for which we can/should not change the priority
*/
opts.joinable = 1;
opts.priority = epicsThreadPriorityScanLow;
tid = epicsThreadCreateOpt("RING", testInThread, stop, &opts);
epicsEventMustWait(stop);
epicsThreadMustJoin(tid);
epicsEventDestroy(stop);
return testDone();
}