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
1diff --git a/src/ioc/db/dbChannel.c b/src/ioc/db/dbChannel.c
2index 399d13d..f355af9 100644
3--- a/src/ioc/db/dbChannel.c
4+++ b/src/ioc/db/dbChannel.c
5@@ -67,6 +67,7 @@ void dbChannelInit (void)
6 freeListInitPvt(&dbChannelFreeList, sizeof(dbChannel), 128);
7 freeListInitPvt(&chFilterFreeList, sizeof(chFilter), 64);
8 freeListInitPvt(&dbchStringFreeList, sizeof(epicsOldString), 128);
9+ db_init_event_freelists();
10 }
11
12 static void chf_value(parseContext *parser, parse_result *presult)
13diff --git a/src/ioc/db/dbEvent.c b/src/ioc/db/dbEvent.c
14index d1f9548..f89c685 100644
15--- a/src/ioc/db/dbEvent.c
16+++ b/src/ioc/db/dbEvent.c
17@@ -153,7 +153,7 @@ int dbel ( const char *pname, unsigned level )
18 if ( ! pname ) return DB_EVENT_OK;
19 status = dbNameToAddr ( pname, &addr );
20 if ( status != 0 ) {
21- errMessage ( status, " dbNameToAddr failed" );
22+ errMessage ( status, " dbNameToAddr failed" );
23 return DB_EVENT_ERROR;
24 }
25
26@@ -162,7 +162,7 @@ int dbel ( const char *pname, unsigned level )
27 pevent = (struct evSubscrip *) ellFirst ( &addr.precord->mlis );
28
29 if ( ! pevent ) {
30- printf ( "\"%s\": No PV event subscriptions ( monitors ).\n", pname );
31+ printf ( "\"%s\": No PV event subscriptions ( monitors ).\n", pname );
32 UNLOCKREC (addr.precord);
33 return DB_EVENT_OK;
34 }
35@@ -174,14 +174,14 @@ int dbel ( const char *pname, unsigned level )
36 pdbFldDes = dbChannelFldDes(pevent->chan);
37
38 if ( level > 0 ) {
39- printf ( "%4.4s", pdbFldDes->name );
40+ printf ( "%4.4s", pdbFldDes->name );
41
42- printf ( " { " );
43+ printf ( " { " );
44 if ( pevent->select & DBE_VALUE ) printf( "VALUE " );
45 if ( pevent->select & DBE_LOG ) printf( "LOG " );
46 if ( pevent->select & DBE_ALARM ) printf( "ALARM " );
47 if ( pevent->select & DBE_PROPERTY ) printf( "PROPERTY " );
48- printf ( "}" );
49+ printf ( "}" );
50
51 if ( pevent->npend ) {
52 printf ( " undelivered=%ld", pevent->npend );
53@@ -236,7 +236,7 @@ int dbel ( const char *pname, unsigned level )
54 ( void * ) pevent->ev_que->evUser );
55 }
56
57- printf( "\n" );
58+ printf( "\n" );
59 }
60
61 pevent = (struct evSubscrip *) ellNext ( &pevent->node );
62@@ -247,23 +247,17 @@ int dbel ( const char *pname, unsigned level )
63 return DB_EVENT_OK;
64 }
65
66+
67 /*
68- * DB_INIT_EVENTS()
69+ * DB_INIT_EVENT_FREELISTS()
70 *
71 *
72- * Initialize the event facility for this task. Must be called at least once
73- * by each task which uses the db event facility
74+ * Initialize the free lists used by the event facility.
75+ * Safe to be called multiple times.
76 *
77- * returns: ptr to event user block or NULL if memory can't be allocated
78 */
79-dbEventCtx db_init_events (void)
80+void db_init_event_freelists (void)
81 {
82- struct event_user * evUser;
83-
84- if (!stopSync) {
85- stopSync = epicsMutexMustCreate();
86- }
87-
88 if (!dbevEventUserFreeList) {
89 freeListInitPvt(&dbevEventUserFreeList,
90 sizeof(struct event_user),8);
91@@ -280,6 +274,26 @@ dbEventCtx db_init_events (void)
92 freeListInitPvt(&dbevFieldLogFreeList,
93 sizeof(struct db_field_log),2048);
94 }
95+}
96+
97+/*
98+ * DB_INIT_EVENTS()
99+ *
100+ *
101+ * Initialize the event facility for this task. Must be called at least once
102+ * by each task which uses the db event facility
103+ *
104+ * returns: ptr to event user block or NULL if memory can't be allocated
105+ */
106+dbEventCtx db_init_events (void)
107+{
108+ struct event_user * evUser;
109+
110+ if (!stopSync) {
111+ stopSync = epicsMutexMustCreate();
112+ }
113+
114+ db_init_event_freelists();
115
116 evUser = (struct event_user *)
117 freeListCalloc(dbevEventUserFreeList);
118@@ -381,7 +395,7 @@ void db_close_events (dbEventCtx ctx)
119 */
120 static struct event_que * create_ev_que ( struct event_user * const evUser )
121 {
122- struct event_que * const ev_que = (struct event_que *)
123+ struct event_que * const ev_que = (struct event_que *)
124 freeListCalloc ( dbevEventQueueFreeList );
125 if ( ! ev_que ) {
126 return NULL;
127@@ -425,7 +439,7 @@ dbEventSubscription db_add_event (
128 while ( TRUE ) {
129 int success = 0;
130 LOCKEVQUE ( ev_que );
131- success = ( ev_que->quota + ev_que->nCanceled <
132+ success = ( ev_que->quota + ev_que->nCanceled <
133 EVENTQUESIZE - EVENTENTRIES );
134 if ( success ) {
135 ev_que->quota += EVENTENTRIES;
136@@ -1093,7 +1107,7 @@ int db_start_events (
137 taskname = EVENT_PEND_NAME;
138 }
139 evUser->taskid = epicsThreadCreate (
140- taskname, osiPriority,
141+ taskname, osiPriority,
142 epicsThreadGetStackSize(epicsThreadStackMedium),
143 event_task, (void *)evUser);
144 if (!evUser->taskid) {
145@@ -1108,7 +1122,7 @@ int db_start_events (
146 /*
147 * db_event_change_priority()
148 */
149-void db_event_change_priority ( dbEventCtx ctx,
150+void db_event_change_priority ( dbEventCtx ctx,
151 unsigned epicsPriority )
152 {
153 struct event_user * const evUser = ( struct event_user * ) ctx;
154diff --git a/src/ioc/db/dbEvent.h b/src/ioc/db/dbEvent.h
155index 2e496a7..7fc6198 100644
156--- a/src/ioc/db/dbEvent.h
157+++ b/src/ioc/db/dbEvent.h
158@@ -50,6 +50,7 @@ epicsShareFunc int db_post_events (
159 typedef void * dbEventCtx;
160
161 typedef void EXTRALABORFUNC (void *extralabor_arg);
162+void db_init_event_freelists (void);
163 epicsShareFunc dbEventCtx db_init_events (void);
164 epicsShareFunc int db_start_events (
165 dbEventCtx ctx, const char *taskname, void (*init_func)(void *),
166@@ -64,7 +65,7 @@ epicsShareFunc int db_post_extra_labor (dbEventCtx ctx);
167 epicsShareFunc void db_event_change_priority ( dbEventCtx ctx, unsigned epicsPriority );
168
169 typedef void EVENTFUNC (void *user_arg, struct dbChannel *chan,
170- int eventsRemaining, struct db_field_log *pfl);
171+ int eventsRemaining, struct db_field_log *pfl);
172
173 typedef void * dbEventSubscription;
174 epicsShareFunc dbEventSubscription db_add_event (

Subscribers

People subscribed via source and target branches