Skip to content

Commit

Permalink
Merge 5713c94 into bc9415b
Browse files Browse the repository at this point in the history
  • Loading branch information
mdavidsaver committed Nov 15, 2022
2 parents bc9415b + 5713c94 commit 8431cd7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
3 changes: 3 additions & 0 deletions modules/libcom/src/osi/os/posix/osdThread.c
Expand Up @@ -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;
}
Expand Down
29 changes: 22 additions & 7 deletions modules/libcom/test/ringPointerTest.c
Expand Up @@ -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();
}

0 comments on commit 8431cd7

Please sign in to comment.