Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > POSIX semaphores in JNI?

Reply
Thread Tools

POSIX semaphores in JNI?

 
 
Kevin McMurtrie
Guest
Posts: n/a
 
      07-24-2004
Can POSIX semaphores be used in Java 1.4.2 JNI code? I have a C++ image
rendering library that is I/O, memory, and CPU intensive. The
operations can be lengthy and various stages of rendering are cached.

The thread management is fairly complex and fined-grained to make sure
that operations do not interfere with each other, especially during I/O.
Is it OK to use POSIX recursive semaphores to control threading? The
JNI docs don't mention it. Information on the web conflicts or is
obsolete (mentions green threads problem).

MacOS X uses 1:1 pthreads. For Linux and Solaris, I'm not sure if the
POSIX routines are safe. JNI threading could replace POSIX threading
but I'm worried about its performance with large caches and numbers of
semaphores. Also, maintaining proper references to the Java sync
objects will be non-trivial. This library has an eventual memory
corruption problem on Solaris only. I don't know if I should spend two
days rewriting my semaphore C++ class for JNI threading or keep looking
for the usual C++ memory bugs. The crash takes 6 to 12 hours to appear
so debugging is time consuming.


Thanks
 
Reply With Quote
 
 
 
 
Stefan Poehn
Guest
Posts: n/a
 
      07-26-2004
"Kevin McMurtrie" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> Can POSIX semaphores be used in Java 1.4.2 JNI code? I have a C++ image
> rendering library that is I/O, memory, and CPU intensive. The
> operations can be lengthy and various stages of rendering are cached.
>


I have used Win32 and vxWorks Semaphores in a JNI project (2 years ago) and
both worked fine. Are the vxWorks semaphores posix compliant?

If you call a method that blocks on a taken semaphore, it does not matter if
you call from C/C++ or Java, all methods will block.

The only pitfall I have encountered is: You cannot create a thread in C/C++
and send any calls to the java virtual machine before you call
AttachCurrentThread.

> The thread management is fairly complex and fined-grained to make sure
> that operations do not interfere with each other, especially during I/O.
> Is it OK to use POSIX recursive semaphores to control threading? The
> JNI docs don't mention it. Information on the web conflicts or is
> obsolete (mentions green threads problem).
>
> MacOS X uses 1:1 pthreads. For Linux and Solaris, I'm not sure if the
> POSIX routines are safe. JNI threading could replace POSIX threading
> but I'm worried about its performance with large caches and numbers of
> semaphores. Also, maintaining proper references to the Java sync
> objects will be non-trivial. This library has an eventual memory
> corruption problem on Solaris only. I don't know if I should spend two
> days rewriting my semaphore C++ class for JNI threading or keep looking
> for the usual C++ memory bugs. The crash takes 6 to 12 hours to appear
> so debugging is time consuming.
>
>
> Thanks



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Posix semaphores FiLH C Programming 11 10-01-2005 10:52 PM
weird problem in buffer using semaphores Moiz Java 0 09-27-2005 12:10 AM
buffer implementation using semaphores metrix007@yahoo.com Java 12 09-24-2005 12:39 PM
Unkillable process because of using semaphores? Nish C++ 1 09-30-2004 06:20 PM
Java JVM crash with semaphores and JNI Fuma Java 0 06-27-2004 03:34 AM



Advertisments