LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-21-2012, 02:07 AM   #1
D1ver
Member
 
Registered: Jan 2010
Distribution: Slackware 13.37
Posts: 598
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Software Design For Embedded Linux System with Multiple Asynchronous Processes


Hello,
I'm in the process of designing a small hobby project using an embedded Linux board (such as the Raspberry Pi) and am having some trouble wrapping my head around my system architecture.

So the system is going to require a few separate processes, each of which share some common configuration information (Probably through a SQlite database). For example,
- There is going to be a process which monitors push-buttons connected to the GPIO pins and provides a simple menu interface on an 7-seg display connected through SPI.

- There is going to be a process which creates a web socket to listen for incoming connections from something like a Labview or Simulink GUI.

- There will probably also be a Html Web interface which will be able to relay/change configuration information.

- There will be another 'heavy-lifting' task which reads information from peripheral sensors (serial/i2c compass or range finder etc) and calculates results. This process will rely on configuration variables stored in the database that the other processes have the ability to change.

I'm used to bare-metal embedded systems where most of this would be in a single process and rely heavily on interrupts.

I'd like to take advantage of Linux as much as possible (and avoid trying to have it all in one multi-threaded/forked C program), so the processes would need someway to communicate between themselves.

I've been reading about UNIX domain sockets, POSIX message queues, FIFOs and other IPC's, and they look like they will do the job. I'm thinking I'd have to devise some message passing system to let process A let process B know that 'table foo has new data'.. So I guess I'd #define out all permutations of these events and pass messages to each process whenever a database write occurs?

Am I on the right track here or am I re-inventing the wheel somehow..

Last edited by D1ver; 09-21-2012 at 02:58 AM.
 
Old 09-21-2012, 09:10 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Your approach seems reasonable and conventional. You are creating a simple control system or SCADA system. Most of these are based on some kind of central database or data sharing scheme. Using a relational database to serve this purpose can be done, although it is a bit heavy and performance may become an issue if the system is intended to scale up. CORBA and similar technologies are often used as the basis for efficient and scalable data sharing in SCADA and control system software. Real-time OS's such as vxWorks tend to provide a more appropriate framework for real-time multitasking and the built-in named-symbol libraries can be an efficient light-weight data sharing mechanism, although the cost probably puts it out of range of a hobbyist.
If your system is composed of a sort of network of IPC schemes, it may become a maintenance and upgrade nightmare. I would consider an approach that uses relatively few of these, and tries to generalize the data sharing and event propagation system.
In contrast to the common wisdom, I see nothing wrong with selective re-invention of wheels or any other machinery. If someone hadn't reinvented the wheel, we might all still be using square wheels (although triangular wheels eliminate one bump per revolution).
--- rod.
 
1 members found this post helpful.
Old 09-21-2012, 10:45 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939
Above all else, start looking for frameworks that are designed to handle tasks similar to yours. No matter what you are doing here, you are not the first. You should be able to find a more-or-less industry standard framework that has been used and refined by many people with similar objectives, so that you can concentrate on what makes your particular application different, not what makes it the same.

"Actum Ne Agas" -- Do Not Do A Thing Already Done.
 
1 members found this post helpful.
Old 09-22-2012, 04:51 PM   #4
D1ver
Member
 
Registered: Jan 2010
Distribution: Slackware 13.37
Posts: 598

Original Poster
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Thanks for your replies I'll keep reading and see what I can come up with.

Cheers
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
A solution for design a single process's to handle asynchronous I/O socket. Alexlun Programming 4 04-11-2008 08:49 AM
Spring loads system processes multiple times photovergne Mandriva 0 08-29-2007 06:44 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration