On Nov 13, 2007, at 3:03 PM, Ilya Goldberg wrote:
> I've successfully used ramfs to do this, though with much smaller
> files.
> ramfs ships with stock TS kernels (I'm using TS-11).
>
> Basicaly, you make a mount point:
> mkdir /var/ramfs/
> then add something like this to /etc/fstab
> none /var/ramfs ramfs defaults 0 0
>
> Now, any files you create in /var/ramfs will be forced to be kept in
> main RAM without ever going to disk or flash.
> The caveat is that this is resident in RAM, and can never be swapped
> out or de-allocated, so you need enough physical RAM for everything
> you store there as well as everything else you're running. Its nice
> and fast though.
>
I probably forgot to point out the maybe not so obvious - you mmap()
the file you create in all of your independent processes.
In other words once you have your structure defined in some .h file,
instead of malloc(), your processes mmap() the same file, assigning
the pointer returned to your structure pointer. Then presto - all
your processes are sharing the same piece of RAM. They all see the
same thing immediately - the only "synch" is to flush the mapped
memory to physical media (which is probably a noop for ramfs). Linux
is amazingly efficient at doing this kind of thing. We have a multi-
terabyte web-based image server that does this, sharing memory
segments in excess of 2 Gb (obviously not embedded, nor using
ramfs). About the only short-coming of this technique is that
avoiding race conditions and managing concurrency is left entirely to
the implementer. But if you don't care about that, then mmap() is
much easier to use (and much faster) than SysV IPC, not to mention a
semi-full-blown DB. You still can't use real pointers to locally
allocated memory in the shared block - only arrays and offsets.
-I
> -Ilya
>
> On Nov 13, 2007, at 12:19 PM, Art wrote:
>
>> Hello all,
>>
>> I have been working for sometime now on a web based control system.
>> This has both a configuration and operational interface from the web.
>> As well as the same controls in hardware. I have been currently
>> using a sqlite database for storage of the main data. This doesn't
>> seem to be a problem when reading but when I write to the data base
>> this could take some time. I really need this to be real time as in
>> fractions of a second. I have been looking at shared memory
>> (shm.h) to
>> share resources between applications. My problem is the shared
>> memory
>> is not big enuf for 4mg to 10 mg worth of data. there is not much I
>> can do to shrink that size. I really need to share a data structure
>> between applications or process that resides in memory. I would hope
>> there would be a way for me to create that data structure in own
>> program and pass a pointer to another program to access it. I know i
>> would normally get a segmentation error if I try to access memory in
>> another programs space. I may need to other IPC methods but I
>> really
>> want to allow the programs to function independent from each
>> other. I
>> don't really care about race conditions because the data is all last
>> action. I just care what the last change was.
>>
>>
>>
>>
>> Yahoo! Groups Links
>>
>>
>>
>
>
>
>
> Yahoo! Groups Links
>
>
>
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|