Hi James, On Wed, Apr 22, 2020 at 06:32:09PM -0700, James Smart wrote: > On 4/15/2020 11:19 AM, Daniel Wagner wrote: > > > +void > > > +efc_node_transition(struct efc_node *node, > > > + void *(*state)(struct efc_sm_ctx *, > > > + enum efc_sm_event, void *), void *data) > > > +{ > > > + struct efc_sm_ctx *ctx = &node->sm; > > > + > > > + if (ctx->current_state == state) { > > > + efc_node_post_event(node, EFC_EVT_REENTER, data); > > > + } else { > > > + efc_node_post_event(node, EFC_EVT_EXIT, data); > > > + ctx->current_state = state; > > > + efc_node_post_event(node, EFC_EVT_ENTER, data); > > > + } > > > > Why does efc_node_transition not need to take the efc->lock as in > > efc_remote_node_cb? How are the state machine state transitions > > serialized? > > efc_remote_node_cb is a callback called from outside the statemachine, so it > needs to take the lock. efc_node_transition is called from within the > statemachine, after the lock is taken. In general the lock is taken upon > entering the statemachine and released before exiting. There isn't granular > locking within the statemachine. Thanks for explaining. I find such short explanation extremly helpful when looking at code. It might be obvious but not for everyone :) Could you add this as comment somehwere? Thanks, Daniel