Hi Steve, Except for the function prototypes closely matching malloc/free, is there any difference or advantage to using mmap/munmap with MAP_SHARED or the Posix shm_open/shm_unlink calls? As for the location I would recommend /dev/shm instead of /run as the latter is not guaranteed to be memory based at all. (It is not on my slackware systems)
Regards, Jeroen On 03/19/2019 05:12 PM, Steve wrote: > I've always been interested in Shared Memory. It was like the > dual-port memory chips that were popular in the 80's. Simultaneous > Memory access by two ALU's. > > Truth be told, I never really used multiple-write. Instead, only > one-write, read-many in software. Then too, I always liked the file > interface, where you can find the memory by just indexing a file name. > > Linux uses the /run as a temp file system. It is completely RAM, so > nothing spinning, By storing your shared memory here, multiple > processes can easily locate and access it. What would really be nice, > is if there was a dynamic library that let you use malloc and free to > offload heap storage onto shared memory. Well there is! It's the OSSP > mm tool. > > The mm tool has very little docs and very little references. Doing a > Google search finds almost nothing. Loading the tool creates a version > that doesn't use a temp file system. I compiled the tool to enable > that, but found the whole thing bloated. So I loaded it into my IDE > and smashed the hell out of it. Thus it became MemoryPool. > > MemoryPool just has one-write read-many. It just uses the Linux temp > file system (/run). Thus, rather than having multiple threads reading > a common heap, you can have multiple threads, or even multiple > processes sharing a common memory. > > The best part, after just a little create/destroy wrapper for the > pool, all you need to do is make a define macro to substitute > malloc/free with MP_malloc/MP_free. > > I'm sure this is not a cure-all, and maybe even has some unacceptable > costs for some, but I thought I'd throw this out in the wild as an > option for your toolbox. > > https://github.com/srsampson/MemoryPool > > Have fun! > Steve/k5okc > > > _______________________________________________ > Freetel-codec2 mailing list > Freetel-codec2@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/freetel-codec2 > _______________________________________________ Freetel-codec2 mailing list Freetel-codec2@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freetel-codec2