EPICS Home

Experimental Physics and Industrial Control System


 
2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  <20202021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  <20202021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: [Merge] ~dirk.zimoch/epics-base:InitEventFreelistsEarly into epics-base:3.15
From: Dirk Zimoch via Core-talk <core-talk at aps.anl.gov>
To: mp+379750 at code.launchpad.net
Date: Mon, 24 Feb 2020 15:23:23 -0000
Dirk Zimoch has proposed merging ~dirk.zimoch/epics-base:InitEventFreelistsEarly into epics-base:3.15.

Requested reviews:
  EPICS Core Developers (epics-core)

For more details, see:
https://code.launchpad.net/~dirk.zimoch/epics-base/+git/epics-base/+merge/379750

This change allows to use the event freelists in dbChannel before Channel Access has started (i.e. during PINI).
-- 
Your team EPICS Core Developers is requested to review the proposed merge of ~dirk.zimoch/epics-base:InitEventFreelistsEarly into epics-base:3.15.
diff --git a/src/ioc/db/dbChannel.c b/src/ioc/db/dbChannel.c
index 399d13d..f355af9 100644
--- a/src/ioc/db/dbChannel.c
+++ b/src/ioc/db/dbChannel.c
@@ -67,6 +67,7 @@ void dbChannelInit (void)
     freeListInitPvt(&dbChannelFreeList,  sizeof(dbChannel), 128);
     freeListInitPvt(&chFilterFreeList,  sizeof(chFilter), 64);
     freeListInitPvt(&dbchStringFreeList, sizeof(epicsOldString), 128);
+    db_init_event_freelists();
 }
 
 static void chf_value(parseContext *parser, parse_result *presult)
diff --git a/src/ioc/db/dbEvent.c b/src/ioc/db/dbEvent.c
index d1f9548..f89c685 100644
--- a/src/ioc/db/dbEvent.c
+++ b/src/ioc/db/dbEvent.c
@@ -153,7 +153,7 @@ int dbel ( const char *pname, unsigned level )
     if ( ! pname ) return DB_EVENT_OK;
     status = dbNameToAddr ( pname, &addr );
     if ( status != 0 ) {
-	    errMessage ( status, " dbNameToAddr failed" );
+        errMessage ( status, " dbNameToAddr failed" );
         return DB_EVENT_ERROR;
     }
 
@@ -162,7 +162,7 @@ int dbel ( const char *pname, unsigned level )
     pevent = (struct evSubscrip *) ellFirst ( &addr.precord->mlis );
 
     if ( ! pevent ) {
-	    printf ( "\"%s\": No PV event subscriptions ( monitors ).\n", pname );
+        printf ( "\"%s\": No PV event subscriptions ( monitors ).\n", pname );
         UNLOCKREC (addr.precord);
         return DB_EVENT_OK;
     }
@@ -174,14 +174,14 @@ int dbel ( const char *pname, unsigned level )
         pdbFldDes = dbChannelFldDes(pevent->chan);
 
         if ( level > 0 ) {
-	        printf ( "%4.4s", pdbFldDes->name );
+            printf ( "%4.4s", pdbFldDes->name );
 
-	        printf ( " { " );
+            printf ( " { " );
                 if ( pevent->select & DBE_VALUE ) printf( "VALUE " );
                 if ( pevent->select & DBE_LOG ) printf( "LOG " );
                 if ( pevent->select & DBE_ALARM ) printf( "ALARM " );
                 if ( pevent->select & DBE_PROPERTY ) printf( "PROPERTY " );
-	        printf ( "}" );
+            printf ( "}" );
 
             if ( pevent->npend ) {
                 printf ( " undelivered=%ld", pevent->npend );
@@ -236,7 +236,7 @@ int dbel ( const char *pname, unsigned level )
                     ( void * ) pevent->ev_que->evUser );
             }
 
-	        printf( "\n" );
+            printf( "\n" );
         }
 
             pevent = (struct evSubscrip *) ellNext ( &pevent->node );
@@ -247,23 +247,17 @@ int dbel ( const char *pname, unsigned level )
     return DB_EVENT_OK;
 }
 
+
 /*
- * DB_INIT_EVENTS()
+ * DB_INIT_EVENT_FREELISTS()
  *
  *
- * Initialize the event facility for this task. Must be called at least once
- * by each task which uses the db event facility
+ * Initialize the free lists used by the event facility.
+ * Safe to be called multiple times.
  *
- * returns: ptr to event user block or NULL if memory can't be allocated
  */
-dbEventCtx db_init_events (void)
+void db_init_event_freelists (void)
 {
-    struct event_user * evUser;
-
-    if (!stopSync) {
-        stopSync = epicsMutexMustCreate();
-    }
-
     if (!dbevEventUserFreeList) {
         freeListInitPvt(&dbevEventUserFreeList,
             sizeof(struct event_user),8);
@@ -280,6 +274,26 @@ dbEventCtx db_init_events (void)
         freeListInitPvt(&dbevFieldLogFreeList,
             sizeof(struct db_field_log),2048);
     }
+}
+
+/*
+ * DB_INIT_EVENTS()
+ *
+ *
+ * Initialize the event facility for this task. Must be called at least once
+ * by each task which uses the db event facility
+ *
+ * returns: ptr to event user block or NULL if memory can't be allocated
+ */
+dbEventCtx db_init_events (void)
+{
+    struct event_user * evUser;
+
+    if (!stopSync) {
+        stopSync = epicsMutexMustCreate();
+    }
+
+    db_init_event_freelists();
 
     evUser = (struct event_user *)
         freeListCalloc(dbevEventUserFreeList);
@@ -381,7 +395,7 @@ void db_close_events (dbEventCtx ctx)
  */
 static struct event_que * create_ev_que ( struct event_user * const evUser )
 {
-    struct event_que * const ev_que = (struct event_que *) 
+    struct event_que * const ev_que = (struct event_que *)
         freeListCalloc ( dbevEventQueueFreeList );
     if ( ! ev_que ) {
         return NULL;
@@ -425,7 +439,7 @@ dbEventSubscription db_add_event (
     while ( TRUE ) {
         int success = 0;
         LOCKEVQUE ( ev_que );
-        success = ( ev_que->quota + ev_que->nCanceled < 
+        success = ( ev_que->quota + ev_que->nCanceled <
                                 EVENTQUESIZE - EVENTENTRIES );
         if ( success ) {
             ev_que->quota += EVENTENTRIES;
@@ -1093,7 +1107,7 @@ int db_start_events (
          taskname = EVENT_PEND_NAME;
      }
      evUser->taskid = epicsThreadCreate (
-         taskname, osiPriority, 
+         taskname, osiPriority,
          epicsThreadGetStackSize(epicsThreadStackMedium),
          event_task, (void *)evUser);
      if (!evUser->taskid) {
@@ -1108,7 +1122,7 @@ int db_start_events (
 /*
  * db_event_change_priority()
  */
-void db_event_change_priority ( dbEventCtx ctx, 
+void db_event_change_priority ( dbEventCtx ctx,
                                         unsigned epicsPriority )
 {
     struct event_user * const evUser = ( struct event_user * ) ctx;
diff --git a/src/ioc/db/dbEvent.h b/src/ioc/db/dbEvent.h
index 2e496a7..7fc6198 100644
--- a/src/ioc/db/dbEvent.h
+++ b/src/ioc/db/dbEvent.h
@@ -50,6 +50,7 @@ epicsShareFunc int db_post_events (
 typedef void * dbEventCtx;
 
 typedef void EXTRALABORFUNC (void *extralabor_arg);
+void db_init_event_freelists (void);
 epicsShareFunc dbEventCtx db_init_events (void);
 epicsShareFunc int db_start_events (
     dbEventCtx ctx, const char *taskname, void (*init_func)(void *),
@@ -64,7 +65,7 @@ epicsShareFunc int db_post_extra_labor (dbEventCtx ctx);
 epicsShareFunc void db_event_change_priority ( dbEventCtx ctx, unsigned epicsPriority );
 
 typedef void EVENTFUNC (void *user_arg, struct dbChannel *chan,
-	int eventsRemaining, struct db_field_log *pfl);
+    int eventsRemaining, struct db_field_log *pfl);
 
 typedef void * dbEventSubscription;
 epicsShareFunc dbEventSubscription db_add_event (

Replies:
Re: [Merge] ~dirk.zimoch/epics-base:InitEventFreelistsEarly into epics-base:3.15 Dirk Zimoch via Core-talk

Navigate by Date:
Prev: Re: [Merge] ~dirk.zimoch/epics-base:dbChannelForDBLinks into epics-base:7.0 Dirk Zimoch via Core-talk
Next: Codacy update Karl Vestin via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  <20202021  2022  2023  2024 
Navigate by Thread:
Prev: Re: qt-creator >=4.8 PSA Michael Davidsaver via Core-talk
Next: Re: [Merge] ~dirk.zimoch/epics-base:InitEventFreelistsEarly into epics-base:3.15 Dirk Zimoch via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  <20202021  2022  2023  2024