12 messages in net.java.dev.jna.usersRe: [jna-users] JNA problems when wor...
FromSent OnAttachments
Stas OskinSep 17, 2008 5:06 am 
Timothy WallSep 17, 2008 6:07 am 
Stas OskinSep 17, 2008 9:55 am 
Timothy WallSep 17, 2008 10:39 am 
Wayne MeissnerSep 17, 2008 10:54 am 
Stas OskinSep 17, 2008 11:07 am 
Timothy WallSep 17, 2008 11:30 am 
Stas OskinSep 18, 2008 2:00 am 
Timothy WallSep 18, 2008 5:50 am 
Stas OskinSep 18, 2008 7:37 am 
Stas OskinSep 18, 2008 11:04 am 
Timothy WallSep 18, 2008 11:29 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] JNA problems when working with shared memoryActions...
From:Stas Oskin (stas@gmail.com)
Date:Sep 17, 2008 9:55:49 am
List:net.java.dev.jna.users

Hi.

Are you checking the return value of shmget and shmat for errors?

I can only check it for shmget - smat returns pointer or -1 in case of error, which JNA doesn't support.

Does your Java code get pointers at startup and use them throughout the run, or do the shared memory pointers come and go? A Pointer is effectively immutable (you have to purposely change its underlying value), so any "corruption" would have to happen when it's returned from shmat.

I get them at start and use the same pointers during the whole life of the application. I don't change them anywhere in the app during it's run.

Look at the "corrupted" pointer values to see what they look like. If there's a pattern, you can check for it and at least throw an exception before failure.

Ok, I will try to follow your masks advices

You probably need to synchronize the native library accesses in order for JNA's protected mode to work (it's not intended as a failsafe mechanism but as a more limited debug tool).

Do you mean I need to ensure thread safety? AFAIK these calls are thread-safe.

Also, what other high-speed IPC methods could be recommended?

Sockets, but that's more complicated than shared memory.

What about memory-mapped files, do you know how these compare in performance to shared memory?

It worth mentioning that my operations are one way, I mean the native app writes the data to shared memory and Java app reads it - there is no need to sync them.

Thanks for the help.