Correct architecture for a small application?


I’m trying to understand how to correctly architecture a very simple Legato application. Application logic will be implemented as a Finite State Automaton. The automaton transitions from one state to another one depending on two types of events:

  • asynchronous events, reported by associated handlers (connection state handler, timer handler, etc.)
  • synchronous events (e.g. a failure reported by a socket write operation). Such an event can only appear when a handler is being executed (e.g. the timer handler was called and tried to send a message over a TCP socket)

My application will not start any thread. So it seems that there will be only one thread running, the main one. Consequently, there will be only one event loop. This means that execution of event handlers is serialized (while an event handler is running, Legato does not run another one). Is it correct?

If yes, it means that I don’t have to provide a mutual exclusion mechanism when transitioning from one automaton state to another one. If not, I have to…

Yes, you are correct. Legato does not start extra threads, so you will only have one thread running (the main one) and you do not need to use any thread synchronization mechanism in the scenario you described.



Perfect, thanks Jen!