Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (711)
Games in Android Showcase (213)
games submitted by our members
Games in WIP (785)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Using MappedByteBuffer for shared memory  (Read 2338 times)
0 Members and 1 Guest are viewing this topic.
Offline Brian

Junior Newbie

Java games rock!

« Posted 2004-11-19 17:34:56 »

I read in Practical Game Programming in Java that MappedByteBuffers could be used for passing data between processes.  If I wanted to use such a buffer to pass data between processes, what's a good way of notifying the other process that there's new data to be read from the buffer?

Offline jbanes

JGO Coder

Projects: 1

"Java Games? Incredible! Mr. Incredible, that is!"

« Reply #1 - Posted 2004-11-19 17:52:23 »

This article (scroll down to "Memory-Mapped Files") explains the situation fairly well. Bascially, using Mapped files for RPC is not guaranteed functionality, and thus is not recommended. You also don't know what kind of delay there might be between updates of the memory block (for systems where the block is not identical memory locations).

None the less, your problem can be solved with polling. The exact way to handle things depends upon what you want to do. i.e. Are you using a server to push to a set of client processes, or are you attempting back and forth communication?

With the former case, you could have a four byte header (an int) at the top of the block, with a packet counter. If the packet counter increases, your program knows that the data has changed. If you need the writes to be synchronous, you can use an extra byte per process as an "ACKnowledge" flag. When the server process writes the data, it sets the ACK flag to 0. After the receiving process is done reading, it sets the flag to 1.

A similar approach can be taken in the later case. Instead of using one block, however, I recommend that you make use of two blocks. Each process with the server of one block and the client of the other.

Does that help?

Edit: RPC should be IPC. RPC wouldn't work very well this way. Wink

Java Game Console Project
Last Journal Entry: 12/17/04
Offline Brian

Junior Newbie

Java games rock!

« Reply #2 - Posted 2004-11-19 17:54:49 »

Helps alot -- thanks much!  Brian
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

numerical (360 views)
2017-02-21 07:32:16

numerical (361 views)
2017-02-21 07:31:46

theagentd (472 views)
2017-02-18 13:42:33

theagentd (470 views)
2017-02-18 13:35:16

h.pernpeintner (1637 views)
2017-01-24 22:39:11

h.pernpeintner (1624 views)
2017-01-24 22:38:32

Galdo (2193 views)
2017-01-12 13:44:09

Archive (2152 views)
2017-01-02 05:31:41

0AndrewShepherd0 (2692 views)
2016-12-16 03:58:39

0AndrewShepherd0 (2355 views)
2016-12-15 21:50:57
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!