Re: Shared memory IPC using NIO memory-mapped files -- anyone done this?
Brian Maso <[email protected]>
| Newsgroups | gmane.comp.windows.devel.java.advanced |
|---|---|
| Message-ID | <20070818193510.UQYN16518.fed1rmmtao106.cox.net@fed1rmimpo02.cox.net> |
At 08:19 AM 8/18/2007, you wrote: >Memory mapped files are not the way to got about this. Having to write >everything to disk would kind of kill your "high performance" requirement. >:) Allegedly, using memory-mapped files the disk IO is spared -- or maybe I just have the wrong idea about that? Brian Maso >You'll need JNI code which wraps unix domain sockets. If that isn't fast >enough, wrap true shared memory with JNI. Use shared memory to actually >share the data and the sockets to coordinate between processes. OK, so use more traditional IPC mechanism to coordinate the consumer/processor choreography. I thought maybe that would be the case, but wanted to make sure. Thanks! >I would start off with network sockets. If those aren't fast enough, they'll >be easy enough to replace w/ domain sockets (the native API is identical). >Bob > >On 8/18/07, Brian Maso <[email protected]> wrote: > > > > Java NIO supports memory-mapped files, which has the cool ability to > > allow multiple apps to share the same array of data if they all map > > the same file in to their respective address spaces. > > > > I've wondered about using memory-mapped files for inter-process > > communication for a while. Someone I know is asking me whether or not > > this is good to use for high-performance communication between Java > > and C++ -- basically sharing fixed-length records between Java and a > > C/C++ program in a producer/consumer sort of system. > > > > It seems like memory-mapped files would be ideal for sharing data > > like this. A Java app could extract data from some source and put it > > in to a MappedByteBuffer, which would immediately be visible to any > > other app on the same box that has mapped the same file. However, I > > can't figure out how the Java process would "signal" the external > > app, indicating that a new record is available for consumption, or > > alternatively how an external app would signal the Java app to tell > > it to write out a new record to the shared memory space. > > > > Anyone familiar with shared memory inter-process communication out > > there who can give me a hint? Google and the regular sources aren't > > revealing anything to me this morning. > > > > Brian Maso > > > > =================================== > > This list is hosted by DevelopMentor(r) http://www.develop.com > > > > View archives and manage your subscription(s) at > > http://discuss.develop.com > > > >=================================== >This list is hosted by DevelopMentor® http://www.develop.com > >View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com