Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.development.apps > #607

Re: Multi threaded embedded linux application state machine design

From Jasen Betts <jasen@xnet.co.nz>
Newsgroups comp.os.linux.development.apps
Subject Re: Multi threaded embedded linux application state machine design
Date 2013-08-22 08:18 +0000
Organization JJ's own news server
Message-ID <kv4hgi$fc3$1@gonzo.reversiblemaps.ath.cx> (permalink)
References <0a9691b3-a57a-40fa-96ea-5314daa87fe6@googlegroups.com>

Show all headers | View raw


On 2013-08-21, Hari Prasath <gehariprasath@gmail.com> wrote:
> Problem definition:

> The system needs to drive or control RS485 slave devices over UART using Modbus. The system also need to control few IO lines like Cooler ON/OFF etc.We believe that a state machine is essential to define this application. The core application shall be a multi threaded application which shall have the following threads...
>
>     Main thread
>     Thread to control the RS485 slaves.
>     Thread to handle events from the Web interface.
>     Thread to handle digital I/O events.
>     Thread to handle commands over TCP/IP(Sockets)

I single thread for tcp/ip ? I guess if you can do it without extra
state that could work.

> For inter-thread communication, we are using Pthread condition signal & wait.  As per our initial design approach(one state machine in main thread), any input event to the system(web or tcp/ip or digital I/O) shall be relayed to the main thread and it shall communicate to the appropriate thread for which the event is destined. A typical scenario would be to get the status of the RS485 slave through the web interface. In this case, the web interface thread shall relay the event to the main thread which shall change the state and then communicate the event to the thread that control's the RS485 slaves & respond back. The main thread shall send the response back to the web interface thread.
>
> Questions:
>
>     Should each thread have its own state machine thereby reducing the complexity of the main thread ?

only if it has state, and if so the a state machine is a good way to
handle it..

> In such a case, should we still need to have a state machine in main thread ?

Only if the system being controlled needs internal state.

-- 
⚂⚃ 100% natural

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---

Back to comp.os.linux.development.apps | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Multi threaded embedded linux application state machine design Hari Prasath <gehariprasath@gmail.com> - 2013-08-21 05:19 -0700
  Re: Multi threaded embedded linux application state machine design Jasen Betts <jasen@xnet.co.nz> - 2013-08-22 08:18 +0000
  Re: Multi threaded embedded linux application state machine design Miloš Rađenović <semicode@gmail.com> - 2014-03-26 16:10 -0700

csiph-web