dynamopsychism has asked for the wisdom of the Perl Monks concerning the following question:

Here's a doozy.

I have 50 or so custom-developed serial devices that I'm controlling via a multiport serial board. All of the devices need to be able to talk to one another, so data from one device needs to be able to be routed to any other (contention issues notwithstanding).

Here's my current problem: there needs to be a master "database" of the state information for all of the devices. I currently have one program running per serial port that does serial I/O and connects to a server, which fork()s a copy of itself off to deal with I/O to that client (note that this is not necessarily the way this must be done, just my current foray). The problem is that I can't think of a Very Fast Way for all of the devices to share a single "database" of data.

I've considered using System V Shared Memory, but have heard bad things about it. I have considered using a real database such as MySQL, but that would be horribly slow considering that each device is read and responded to in microseconds. Ideally I need some way to directly manipulate the same data structure via multiple processes, which I know sounds really stupid.

Any ideas?

Edit by tye

Replies are listed 'Best First'.
Re: Shared data space
by lhoward (Vicar) on May 21, 2001 at 22:27 UTC
    I've used SysV Shared Memory before with great results. It can be a bit hairy if you do all the work yourself, but if you use one of the nice perl OO modules to it its a breeze: fast and reliable. IPC::Shareable IPC::ShareLite
(tye)Re: Shared data space
by tye (Sage) on May 21, 2001 at 22:35 UTC

    Lets say we have devices 'a' though 'z'. Then you could simply use a directory of empty files where a file named "a-c" means that "a" is sending its data to "c".

            - tye (but my friends call me "Tye")
      That's what Cache::FileCache handles for you. You can retrieve Perl data structures based on a key, which in this case would be something 'a-z' or 'c-a' or whatever.

        No, I said empty files.

                - tye (but my friends call me "Tye")
Re: Shared data space
by princepawn (Parson) on May 21, 2001 at 22:16 UTC
    Assuming you want to keep POE out of the picture, then maybe Cache::FileCache will work as a means of IPC.