Merge ~dirk.zimoch/epics-base:InitEventFreelistsEarly into ~epics-core/epics-base/+git/epics-base:3.15

Proposed by Dirk Zimoch
Status: Rejected
Rejected by: Andrew Johnson
Proposed branch: ~dirk.zimoch/epics-base:InitEventFreelistsEarly
Merge into: ~epics-core/epics-base/+git/epics-base:3.15
Diff against target: 174 lines (+38/-22)
3 files modified
src/ioc/db/dbChannel.c (+1/-0)
src/ioc/db/dbEvent.c (+35/-21)
src/ioc/db/dbEvent.h (+2/-1)
Reviewer Review Type Date Requested Status
EPICS Core Developers Pending
Review via email: mp+379750@code.launchpad.net

Description of the change

This change allows to use the event freelists in dbChannel before Channel Access has started (i.e. during PINI).

To post a comment you must log in.
Revision history for this message
Andrew Johnson (anj) wrote :

Hi Dirk,

I believe I have said this before: We have a general rule that new features get added to the 7.0 branch, while bug fixes get applied to the earliest branch that suffers from the bug (often but not always 3.15 nowadays).

Your dbDbLink changes are adding a new feature and were thus correctly proposed for merging into the 7.0 branch (don't try to rebase them against 3.15, except for any bug-fixes which should be discussed separately). Please rebase the changes here against 7.0 where they belong.

Thanks,

- Andrew

Revision history for this message
Dirk Zimoch (dirk.zimoch) wrote :

I thought we had agreed on moving the dbDbLink changes to 3.15, because that is where filters had been introduced ???

I can continue to work on the 7.0 branch of course, but please make sure that there is a consensus in the core team first, as rebasing this is not a simple work (files have been moved around, functionality has been moved to other files).

Revision history for this message
Dirk Zimoch (dirk.zimoch) wrote :

Unmerged commits

f3f873a... by Dirk Zimoch

initialize free lists when starting dbChannel

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
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)
67 freeListInitPvt(&dbChannelFreeList, sizeof(dbChannel), 128);67 freeListInitPvt(&dbChannelFreeList, sizeof(dbChannel), 128);
68 freeListInitPvt(&chFilterFreeList, sizeof(chFilter), 64);68 freeListInitPvt(&chFilterFreeList, sizeof(chFilter), 64);
69 freeListInitPvt(&dbchStringFreeList, sizeof(epicsOldString), 128);69 freeListInitPvt(&dbchStringFreeList, sizeof(epicsOldString), 128);
70 db_init_event_freelists();
70}71}
7172
72static void chf_value(parseContext *parser, parse_result *presult)73static 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 )
153 if ( ! pname ) return DB_EVENT_OK;153 if ( ! pname ) return DB_EVENT_OK;
154 status = dbNameToAddr ( pname, &addr );154 status = dbNameToAddr ( pname, &addr );
155 if ( status != 0 ) {155 if ( status != 0 ) {
156 errMessage ( status, " dbNameToAddr failed" );156 errMessage ( status, " dbNameToAddr failed" );
157 return DB_EVENT_ERROR;157 return DB_EVENT_ERROR;
158 }158 }
159159
@@ -162,7 +162,7 @@ int dbel ( const char *pname, unsigned level )
162 pevent = (struct evSubscrip *) ellFirst ( &addr.precord->mlis );162 pevent = (struct evSubscrip *) ellFirst ( &addr.precord->mlis );
163163
164 if ( ! pevent ) {164 if ( ! pevent ) {
165 printf ( "\"%s\": No PV event subscriptions ( monitors ).\n", pname );165 printf ( "\"%s\": No PV event subscriptions ( monitors ).\n", pname );
166 UNLOCKREC (addr.precord);166 UNLOCKREC (addr.precord);
167 return DB_EVENT_OK;167 return DB_EVENT_OK;
168 }168 }
@@ -174,14 +174,14 @@ int dbel ( const char *pname, unsigned level )
174 pdbFldDes = dbChannelFldDes(pevent->chan);174 pdbFldDes = dbChannelFldDes(pevent->chan);
175175
176 if ( level > 0 ) {176 if ( level > 0 ) {
177 printf ( "%4.4s", pdbFldDes->name );177 printf ( "%4.4s", pdbFldDes->name );
178178
179 printf ( " { " );179 printf ( " { " );
180 if ( pevent->select & DBE_VALUE ) printf( "VALUE " );180 if ( pevent->select & DBE_VALUE ) printf( "VALUE " );
181 if ( pevent->select & DBE_LOG ) printf( "LOG " );181 if ( pevent->select & DBE_LOG ) printf( "LOG " );
182 if ( pevent->select & DBE_ALARM ) printf( "ALARM " );182 if ( pevent->select & DBE_ALARM ) printf( "ALARM " );
183 if ( pevent->select & DBE_PROPERTY ) printf( "PROPERTY " );183 if ( pevent->select & DBE_PROPERTY ) printf( "PROPERTY " );
184 printf ( "}" );184 printf ( "}" );
185185
186 if ( pevent->npend ) {186 if ( pevent->npend ) {
187 printf ( " undelivered=%ld", pevent->npend );187 printf ( " undelivered=%ld", pevent->npend );
@@ -236,7 +236,7 @@ int dbel ( const char *pname, unsigned level )
236 ( void * ) pevent->ev_que->evUser );236 ( void * ) pevent->ev_que->evUser );
237 }237 }
238238
239 printf( "\n" );239 printf( "\n" );
240 }240 }
241241
242 pevent = (struct evSubscrip *) ellNext ( &pevent->node );242 pevent = (struct evSubscrip *) ellNext ( &pevent->node );
@@ -247,23 +247,17 @@ int dbel ( const char *pname, unsigned level )
247 return DB_EVENT_OK;247 return DB_EVENT_OK;
248}248}
249249
250
250/*251/*
251 * DB_INIT_EVENTS()252 * DB_INIT_EVENT_FREELISTS()
252 *253 *
253 *254 *
254 * Initialize the event facility for this task. Must be called at least once255 * Initialize the free lists used by the event facility.
255 * by each task which uses the db event facility256 * Safe to be called multiple times.
256 *257 *
257 * returns: ptr to event user block or NULL if memory can't be allocated
258 */258 */
259dbEventCtx db_init_events (void)259void db_init_event_freelists (void)
260{260{
261 struct event_user * evUser;
262
263 if (!stopSync) {
264 stopSync = epicsMutexMustCreate();
265 }
266
267 if (!dbevEventUserFreeList) {261 if (!dbevEventUserFreeList) {
268 freeListInitPvt(&dbevEventUserFreeList,262 freeListInitPvt(&dbevEventUserFreeList,
269 sizeof(struct event_user),8);263 sizeof(struct event_user),8);
@@ -280,6 +274,26 @@ dbEventCtx db_init_events (void)
280 freeListInitPvt(&dbevFieldLogFreeList,274 freeListInitPvt(&dbevFieldLogFreeList,
281 sizeof(struct db_field_log),2048);275 sizeof(struct db_field_log),2048);
282 }276 }
277}
278
279/*
280 * DB_INIT_EVENTS()
281 *
282 *
283 * Initialize the event facility for this task. Must be called at least once
284 * by each task which uses the db event facility
285 *
286 * returns: ptr to event user block or NULL if memory can't be allocated
287 */
288dbEventCtx db_init_events (void)
289{
290 struct event_user * evUser;
291
292 if (!stopSync) {
293 stopSync = epicsMutexMustCreate();
294 }
295
296 db_init_event_freelists();
283297
284 evUser = (struct event_user *)298 evUser = (struct event_user *)
285 freeListCalloc(dbevEventUserFreeList);299 freeListCalloc(dbevEventUserFreeList);
@@ -381,7 +395,7 @@ void db_close_events (dbEventCtx ctx)
381 */395 */
382static struct event_que * create_ev_que ( struct event_user * const evUser )396static struct event_que * create_ev_que ( struct event_user * const evUser )
383{397{
384 struct event_que * const ev_que = (struct event_que *) 398 struct event_que * const ev_que = (struct event_que *)
385 freeListCalloc ( dbevEventQueueFreeList );399 freeListCalloc ( dbevEventQueueFreeList );
386 if ( ! ev_que ) {400 if ( ! ev_que ) {
387 return NULL;401 return NULL;
@@ -425,7 +439,7 @@ dbEventSubscription db_add_event (
425 while ( TRUE ) {439 while ( TRUE ) {
426 int success = 0;440 int success = 0;
427 LOCKEVQUE ( ev_que );441 LOCKEVQUE ( ev_que );
428 success = ( ev_que->quota + ev_que->nCanceled < 442 success = ( ev_que->quota + ev_que->nCanceled <
429 EVENTQUESIZE - EVENTENTRIES );443 EVENTQUESIZE - EVENTENTRIES );
430 if ( success ) {444 if ( success ) {
431 ev_que->quota += EVENTENTRIES;445 ev_que->quota += EVENTENTRIES;
@@ -1093,7 +1107,7 @@ int db_start_events (
1093 taskname = EVENT_PEND_NAME;1107 taskname = EVENT_PEND_NAME;
1094 }1108 }
1095 evUser->taskid = epicsThreadCreate (1109 evUser->taskid = epicsThreadCreate (
1096 taskname, osiPriority, 1110 taskname, osiPriority,
1097 epicsThreadGetStackSize(epicsThreadStackMedium),1111 epicsThreadGetStackSize(epicsThreadStackMedium),
1098 event_task, (void *)evUser);1112 event_task, (void *)evUser);
1099 if (!evUser->taskid) {1113 if (!evUser->taskid) {
@@ -1108,7 +1122,7 @@ int db_start_events (
1108/*1122/*
1109 * db_event_change_priority()1123 * db_event_change_priority()
1110 */1124 */
1111void db_event_change_priority ( dbEventCtx ctx, 1125void db_event_change_priority ( dbEventCtx ctx,
1112 unsigned epicsPriority )1126 unsigned epicsPriority )
1113{1127{
1114 struct event_user * const evUser = ( struct event_user * ) ctx;1128 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 (
50typedef void * dbEventCtx;50typedef void * dbEventCtx;
5151
52typedef void EXTRALABORFUNC (void *extralabor_arg);52typedef void EXTRALABORFUNC (void *extralabor_arg);
53void db_init_event_freelists (void);
53epicsShareFunc dbEventCtx db_init_events (void);54epicsShareFunc dbEventCtx db_init_events (void);
54epicsShareFunc int db_start_events (55epicsShareFunc int db_start_events (
55 dbEventCtx ctx, const char *taskname, void (*init_func)(void *),56 dbEventCtx ctx, const char *taskname, void (*init_func)(void *),
@@ -64,7 +65,7 @@ epicsShareFunc int db_post_extra_labor (dbEventCtx ctx);
64epicsShareFunc void db_event_change_priority ( dbEventCtx ctx, unsigned epicsPriority );65epicsShareFunc void db_event_change_priority ( dbEventCtx ctx, unsigned epicsPriority );
6566
66typedef void EVENTFUNC (void *user_arg, struct dbChannel *chan,67typedef void EVENTFUNC (void *user_arg, struct dbChannel *chan,
67 int eventsRemaining, struct db_field_log *pfl);68 int eventsRemaining, struct db_field_log *pfl);
6869
69typedef void * dbEventSubscription;70typedef void * dbEventSubscription;
70epicsShareFunc dbEventSubscription db_add_event (71epicsShareFunc dbEventSubscription db_add_event (

Subscribers

People subscribed via source and target branches