fixed priority polarization of event thread

This commit is contained in:
Jeff Hill
2000-06-12 19:16:19 +00:00
parent 0077b27fe3
commit f4e905be5b
4 changed files with 24 additions and 12 deletions

View File

@@ -945,10 +945,9 @@ LOCAL void event_task (void *pParm)
*/
int epicsShareAPI db_start_events (
dbEventCtx ctx,const char *taskname, void (*init_func)(threadId),
void *init_func_arg, int priority_offset)
void *init_func_arg, unsigned osiPriority )
{
struct event_user *evUser = (struct event_user *) ctx;
int taskpri;
semMutexMustTake (evUser->firstque.writelock);
@@ -961,8 +960,6 @@ int epicsShareAPI db_start_events (
return DB_EVENT_OK;
}
taskpri = threadGetPrioritySelf ();
taskpri -= priority_offset;
evUser->pendexit = FALSE;
evUser->init_func = init_func;
evUser->init_func_arg = init_func_arg;
@@ -970,7 +967,7 @@ int epicsShareAPI db_start_events (
taskname = EVENT_PEND_NAME;
}
evUser->taskid = threadCreate (
taskname, taskpri, threadGetStackSize(threadStackMedium),
taskname, osiPriority, threadGetStackSize(threadStackMedium),
event_task, (void *)evUser);
if (!evUser->taskid) {
semMutexGive (evUser->firstque.writelock);

View File

@@ -50,7 +50,7 @@ typedef void EXTRALABORFUNC (void *extralabor_arg);
epicsShareFunc dbEventCtx epicsShareAPI db_init_events (void);
epicsShareFunc int epicsShareAPI db_start_events (
dbEventCtx ctx, const char *taskname, void (*init_func)(void *),
void *init_func_arg, int priority_offset);
void *init_func_arg, unsigned osiPriority );
epicsShareFunc void epicsShareAPI db_close_events (dbEventCtx ctx);
epicsShareFunc void epicsShareAPI db_event_flow_ctrl_mode_on (dbEventCtx ctx);
epicsShareFunc void epicsShareAPI db_event_flow_ctrl_mode_off (dbEventCtx ctx);

View File

@@ -115,7 +115,6 @@ extern "C" void cacAttachClientCtx ( void * pPrivate )
dbEventSubscription dbServiceIO::subscribe ( struct dbAddr &addr, dbSubscriptionIO &subscr, unsigned mask )
{
static const int slightlyHigherPriority = -1;
caClientCtx clientCtx;
dbEventSubscription es;
int status;
@@ -132,10 +131,18 @@ dbEventSubscription dbServiceIO::subscribe ( struct dbAddr &addr, dbSubscription
this->mutex.unlock ();
return 0;
}
unsigned selfPriority = threadGetPrioritySelf ();
unsigned above;
threadBoolStatus tbs = threadLowestPriorityLevelAbove
(selfPriority, &above);
if ( tbs != tbsSuccess ) {
above = selfPriority;
}
status = db_start_events ( this->ctx, "CAC-event",
cacAttachClientCtx, clientCtx, slightlyHigherPriority );
cacAttachClientCtx, clientCtx, above );
if ( status ) {
db_close_events (this->ctx);
db_close_events ( this->ctx );
this->ctx = 0;
return 0;
}

View File

@@ -136,11 +136,13 @@ struct client *create_base_client ()
*/
struct client *create_client (SOCKET sock)
{
static const unsigned slightlyLowerPriority = 1;
int status;
struct client *client;
int true = TRUE;
int addrSize;
unsigned selfPriority;
unsigned below;
threadBoolStatus tbs;
/*
* see TCP(4P) this seems to make unsolicited single events much
@@ -228,8 +230,14 @@ struct client *create_client (SOCKET sock)
return NULL;
}
status = db_start_events (client->evuser, "CAS-event",
NULL, NULL, slightlyLowerPriority);
selfPriority = threadGetPrioritySelf ();
tbs = threadHighestPriorityLevelBelow (selfPriority, &below);
if ( tbs != tbsSuccess ) {
below = selfPriority;
}
status = db_start_events ( client->evuser, "CAS-event",
NULL, NULL, below );
if (status != DB_EVENT_OK) {
errlogPrintf("CAS: unable to start the event facility\n");
destroy_client (client);