From 89e556343743dd84e62f4a025c753729cc2a1c2f Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Thu, 10 Feb 2000 15:46:01 +0000 Subject: [PATCH] get rid of threadGetName --- src/db/Makefile | 4 +-- src/db/callback.c | 70 +++++++++++++++++++++++++++++++++++++++-------- src/db/callback.h | 1 + src/db/recGbl.c | 4 +-- src/db/taskwd.c | 4 +-- 5 files changed, 65 insertions(+), 18 deletions(-) diff --git a/src/db/Makefile b/src/db/Makefile index 5aa9c9b69..45846535c 100644 --- a/src/db/Makefile +++ b/src/db/Makefile @@ -56,8 +56,8 @@ SRCS += initHooks.c SRCS += dbcar.c -LIBRARY = db -DLL_LIBS = Db Com +LIBRARY_IOC = db +DLL_LIBS = dbStaticIoc Com include $(TOP)/configure/RULES diff --git a/src/db/callback.c b/src/db/callback.c index fbcd26e59..33ae7a56e 100644 --- a/src/db/callback.c +++ b/src/db/callback.c @@ -21,6 +21,7 @@ of this distribution. #include "osiSem.h" #include "osiThread.h" #include "osiInterrupt.h" +#include "osiTimer.h" #include "osiRing.h" #include "errlog.h" #include "callback.h" @@ -40,6 +41,16 @@ volatile int callbackRestart=FALSE; static int priorityValue[NUM_CALLBACK_PRIORITIES] = {0,1,2}; +/*for Delayed Requests */ +static void expire(void *pPrivate); +static void destroy(void *pPrivate); +static int again(void *pPrivate); +static double delay(void *pPrivate); +static void show(void *pPrivate, unsigned level); +static osiTimerJumpTable jumpTable = { expire,destroy,again,delay,show}; +static osiTimerQueueId timerQueue; + + /* forward references */ static void wdCallback(void *ind); /*callback from taskwd*/ static void start(int ind); /*start or restart a callbackTask*/ @@ -55,6 +66,7 @@ long callbackInit() { int i; + timerQueue = osiTimerQueueCreate(threadPriorityScanLow); for(i=0; irset->process)(pRec); dbScanUnlock(pRec); } -void callbackRequestProcessCallback(CALLBACK *pCallback, +void callbackRequestProcessCallback(CALLBACK *pcallback, int Priority, void *pRec) { - callbackSetCallback(ProcessCallback, pCallback); - callbackSetPriority(Priority, pCallback); - callbackSetUser(pRec, pCallback); - callbackRequest(pCallback); + callbackSetCallback(ProcessCallback, pcallback); + callbackSetPriority(Priority, pcallback); + callbackSetUser(pRec, pcallback); + callbackRequest(pcallback); } -void callbackRequestDelayed(CALLBACK *pCallback,double seconds) +void expire(void *pPrivate) { - printf("callbackRequestDelayed not yet implemented\n"); + CALLBACK *pcallback = (CALLBACK *)pPrivate; + callbackRequest(pcallback); } -void callbackRequestProcessCallbackDelayed(CALLBACK *pCallback, +void destroy(void *pPrivate) +{ + return; +} + +int again(void *pPrivate) +{ + return(0); +} + +double delay(void *pPrivate) +{ + return(0.0); +} + +void show(void *pPrivate, unsigned level) +{ + return; +} + + +void callbackRequestDelayed(CALLBACK *pcallback,double seconds) +{ + osiTimerId timer = (osiTimerId *)pcallback->timer; + + if(timer==0) { + timer = osiTimerCreate(&jumpTable,(void *)pcallback); + pcallback->timer = timer; + } + osiTimerArm(timer,timerQueue,seconds); +} + +void callbackRequestProcessCallbackDelayed(CALLBACK *pcallback, int Priority, void *pRec,double seconds) { - printf("callbackRequestDelayed not yet implemented\n"); + callbackSetCallback(ProcessCallback, pcallback); + callbackSetPriority(Priority, pcallback); + callbackSetUser(pRec, pcallback); + callbackRequestDelayed(pcallback,seconds); } diff --git a/src/db/callback.h b/src/db/callback.h index a8cb9542f..91ec00d61 100644 --- a/src/db/callback.h +++ b/src/db/callback.h @@ -46,6 +46,7 @@ typedef struct callbackPvt { #endif int priority; void *user; /*for use by callback user*/ + void *timer; /*for use by callback itself*/ }CALLBACK; #ifdef __STDC__ diff --git a/src/db/recGbl.c b/src/db/recGbl.c index d2ba1a28e..c04f2446a 100644 --- a/src/db/recGbl.c +++ b/src/db/recGbl.c @@ -315,10 +315,10 @@ void recGblGetTimeStamp(void* prec) if(pr->tsel.type!=CONSTANT) { dbGetLink(&(pr->tsel), DBR_SHORT,&(pr->tse),0,0); - status = tsStampGetEvent((int)pr->tse,&pr->time); + status = tsStampGetEvent(&pr->time,(unsigned)pr->tse); } else - status = tsStampGetEvent((int)pr->tse,&pr->time); + status = tsStampGetEvent(&pr->time,(unsigned)pr->tse); if(status) errlogPrintf("%s recGblGetTimeStamp failed\n",pr->name); } diff --git a/src/db/taskwd.c b/src/db/taskwd.c index 8642f3aef..81387cf2f 100644 --- a/src/db/taskwd.c +++ b/src/db/taskwd.c @@ -165,15 +165,13 @@ static void taskwdTask(void) while(pt) { next = (struct task_list *)ellNext((void *)pt); if(threadIsSuspended(pt->id.tid)) { - const char *pname; char message[100]; - pname = threadGetName(pt->id.tid); if(!pt->suspended) { struct task_list *ptany; pt->suspended = TRUE; - sprintf(message,"task %s suspended",pname); + sprintf(message,"task %p suspended",pt->id.tid); errMessage(-1,message); ptany = (struct task_list *)ellFirst(&anylist); while(ptany) {