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


Groups > comp.arch.embedded > #24304

Re: Embedded Linux: share data among different processes

From Don Y <blockedofcourse@foo.invalid>
Newsgroups comp.arch.embedded
Subject Re: Embedded Linux: share data among different processes
Date 2016-06-23 12:11 -0700
Organization A noiseless patient Spider
Message-ID <nkhca7$cuk$1@dont-email.me> (permalink)
References <nkgihf$dn7$1@dont-email.me>

Show all headers | View raw


On 6/23/2016 4:52 AM, pozz wrote:
> I'm new to embedded Linux so this question could be very simple for many of
> you. Most probably, it isn't directly related to embedded world, but to Linux
> OS generally. Anyway I think it is a common scenario in embedded applications.
>
> I'm going to develop a local/remote control of an electronic device. It
> communicates through a RS485 link.
> The local control will be a touch-screen display (I'm going to use QT graphic
> libraries).
> The remote control will be HTTP (web server).
>
> I think a good approach will be to develop a simple application, the poller,
> that communicates with the electronic device and implements the RS485 protocol.
> The poller continuously acquires the current status/settings of the device and
> store them in some "shared" way.
>
> The graphic application (QT-based) and the web server (CGI) should access to
> the data retrieved by the poller.
>
> What is the best method to share the data generated by an application (the
> poller) among two or more applications (QT and CGI)?
> In this scenario, I think it's important to lock the "shared data" before
> accessing them (reading or writing), in order to avoid reading incoerent data.
> Indeed, if the poller writes the data at the same time (Linux OS is
> multi-tasking) the web server reads them, they could be incoerent.
>
> I'm thinking to use SQLite database to store the data. The poller writes the
> database, HTTP and QT reads from it. It seems SQLite will take care the
> multi-thread/multi-process scenario.
>
> Any suggestions?

It depends on how "lightweight" you want the mechanism to be.  And,
how "elegant".

If you can implement the "Shared Memory" extensions (a kernel option
in the *BSD's -- not sure re: Linux) then this is the easiest way
forward.  Look for shmget(2), shmat(2), shmctl(2), et al.

Use a semaphore to control access (and discipline for thereaders/writers
to follow that convention) and keep atomic regions short and sweet.

If the data isn't changing all that often, you can push it to each
consumer through pipes and count on them to keep their own copies
intact.  (here, there be dragons)

The DBMS approach is how I am currently addressing all "persistent
data".  It's a fair bit heavier-handed (I've got lots of MIPS to spare)
but is more elegant; a producer can't inject data into the store
unless the data is appropriate for the tables/fields involved
(you can't store text somewhere that expects numerics!).  Likewise,
the consumers need not *check* the data because the checks can be
applied on admission to the DB.  I.e., if the data is *in* the
DB, then you know it satisfied the admission criteria!

However, I don't think SQLite has all of these hooks.

GNeuner is your go-to guy for the DB approach...

Back to comp.arch.embedded | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Embedded Linux: share data among different processes pozz <pozzugno@gmail.com> - 2016-06-23 13:52 +0200
  Re: Embedded Linux: share data among different processes Jack <jack4747@gmail.com> - 2016-06-23 05:30 -0700
    Re: Embedded Linux: share data among different processes Reinhardt Behm <rbehm@hushmail.com> - 2016-06-23 21:05 +0800
      Re: Embedded Linux: share data among different processes Clifford Heath <no.spam@please.net> - 2016-06-24 09:45 +1000
        Re: Embedded Linux: share data among different processes Don Y <blockedofcourse@foo.invalid> - 2016-06-23 17:19 -0700
          Re: Embedded Linux: share data among different processes Clifford Heath <no.spam@please.net> - 2016-06-24 13:25 +1000
            Re: Embedded Linux: share data among different processes Don Y <blockedofcourse@foo.invalid> - 2016-06-23 21:27 -0700
              Re: Embedded Linux: share data among different processes Clifford Heath <no.spam@please.net> - 2016-06-24 14:40 +1000
                Re: Embedded Linux: share data among different processes Don Y <blockedofcourse@foo.invalid> - 2016-06-23 22:20 -0700
                Re: Embedded Linux: share data among different processes Clifford Heath <no.spam@please.net> - 2016-06-24 17:19 +1000
                Re: Embedded Linux: share data among different processes Don Y <blockedofcourse@foo.invalid> - 2016-06-24 01:01 -0700
                Re: Embedded Linux: share data among different processes Dimiter_Popoff <dp@tgi-sci.com> - 2016-06-24 16:38 +0300
                Re: Embedded Linux: share data among different processes Don Y <blockedofcourse@foo.invalid> - 2016-06-24 11:13 -0700
        Re: Embedded Linux: share data among different processes Reinhardt Behm <rbehm@hushmail.com> - 2016-06-24 12:39 +0800
          Re: Embedded Linux: share data among different processes Don Y <blockedofcourse@foo.invalid> - 2016-06-24 01:53 -0700
            Re: Embedded Linux: share data among different processes Reinhardt Behm <rbehm@hushmail.com> - 2016-06-26 09:34 +0800
              Re: Embedded Linux: share data among different processes Don Y <blockedofcourse@foo.invalid> - 2016-06-26 00:30 -0700
        Re: Embedded Linux: share data among different processes Les Cargill <lcargill99@comcast.com> - 2016-06-24 15:18 -0500
  Re: Embedded Linux: share data among different processes Mel Wilson <mwilson@the-wire.com> - 2016-06-23 13:47 +0000
    Re: Embedded Linux: share data among different processes pozz <pozzugno@gmail.com> - 2016-06-24 13:36 +0200
      Re: Embedded Linux: share data among different processes Mel Wilson <mwilson@the-wire.com> - 2016-06-26 15:25 +0000
  Re: Embedded Linux: share data among different processes Don Y <blockedofcourse@foo.invalid> - 2016-06-23 12:11 -0700
    Re: Embedded Linux: share data among different processes pozz <pozzugno@gmail.com> - 2016-06-24 13:40 +0200
      Re: Embedded Linux: share data among different processes Don Y <blockedofcourse@foo.invalid> - 2016-06-24 10:44 -0700
  Re: Embedded Linux: share data among different processes Paul Rubin <no.email@nospam.invalid> - 2016-06-23 12:31 -0700
    Re: Embedded Linux: share data among different processes George Neuner <gneuner2@comcast.net> - 2016-06-23 17:27 -0400
    Re: Embedded Linux: share data among different processes pozz <pozzugno@gmail.com> - 2016-06-24 13:43 +0200
      Re: Embedded Linux: share data among different processes Don Y <blockedofcourse@foo.invalid> - 2016-06-24 10:48 -0700
        Re: Embedded Linux: share data among different processes pozz <pozzugno@gmail.com> - 2016-06-27 14:46 +0200
          Re: Embedded Linux: share data among different processes Don Y <blockedofcourse@foo.invalid> - 2016-06-27 13:41 -0700
      Re: Embedded Linux: share data among different processes Paul Rubin <no.email@nospam.invalid> - 2016-06-24 13:52 -0700
        Re: Embedded Linux: share data among different processes Les Cargill <lcargill99@comcast.com> - 2016-06-24 16:42 -0500
        Re: Embedded Linux: share data among different processes pozz <pozzugno@gmail.com> - 2016-06-27 16:00 +0200
          Re: Embedded Linux: share data among different processes Paul Rubin <no.email@nospam.invalid> - 2016-06-27 20:06 -0700
            Re: Embedded Linux: share data among different processes pozz <pozzugno@gmail.com> - 2016-06-28 08:41 +0200
              Re: Embedded Linux: share data among different processes Paul Rubin <no.email@nospam.invalid> - 2016-06-28 00:27 -0700
                Re: Embedded Linux: share data among different processes pozz <pozzugno@gmail.com> - 2016-06-28 12:50 +0200
                Re: Embedded Linux: share data among different processes Paul Rubin <no.email@nospam.invalid> - 2016-06-28 10:01 -0700
                Re: Embedded Linux: share data among different processes pozz <pozzugno@gmail.com> - 2016-06-29 13:10 +0200
                Re: Embedded Linux: share data among different processes Paul Rubin <no.email@nospam.invalid> - 2016-06-29 10:47 -0700
                Re: Embedded Linux: share data among different processes edward.ming.lee@gmail.com - 2016-06-29 14:01 -0700
                Re: Embedded Linux: share data among different processes pozz <pozzugno@gmail.com> - 2016-06-30 15:11 +0200
                Re: Embedded Linux: share data among different processes edward.ming.lee@gmail.com - 2016-06-30 08:19 -0700
  Re: Embedded Linux: share data among different processes Les Cargill <lcargill99@comcast.com> - 2016-06-23 14:53 -0500
    Re: Embedded Linux: share data among different processes Paul Rubin <no.email@nospam.invalid> - 2016-06-23 13:05 -0700
    Re: Embedded Linux: share data among different processes pozz <pozzugno@gmail.com> - 2016-06-24 13:54 +0200
      Re: Embedded Linux: share data among different processes Les Cargill <lcargill99@comcast.com> - 2016-06-24 14:27 -0500
  Re: Embedded Linux: share data among different processes Les Cargill <lcargill99@comcast.com> - 2016-06-24 16:39 -0500
    Re: Embedded Linux: share data among different processes Don Y <blockedofcourse@foo.invalid> - 2016-06-24 15:11 -0700

csiph-web