dcsimg
jni & multithreaded programming
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, November 25, 2002 01:53 AM

I have a question regarding JNI & multithreaded programming. Here is what I am doing. Java front end ---> C++ main ----> Network server(C++) | |--> Status checker(C++) When java program starts, it calls native function, which is written in C++. Then, the C++ main creates two threads. The structure of it is like this. initialize() pthread_create(.., status_checker, ..) .... while (1) { wait client requests. process the request. } The status checker wakes up periodically and call java method to send the status. For this, it uses sleep system call. T   More>>

I have a question regarding JNI & multithreaded programming.
Here is what I am doing.


			

Java front end ---> C++ main ----> Network server(C++)
|
|--> Status checker(C++)

When java program starts, it calls native function, which is written in C++.
Then, the C++ main creates two threads. The structure of it is like this.
			

initialize()
pthread_create(.., status_checker, ..)

....

while (1) {
wait client requests.
process the request.
}


The status checker wakes up periodically and call java method to send the status. For this, it uses sleep system call.


The problem is when the status checker wakes up and calls java method, the whole program crashes.


I tried several things to see what the problem is and found out one thing interesting.
When I put the statements that call java method right ahead of "wait client request", then everything work well. But if the status checker call the java method while network server threads waits until there is any client request, then it crashes and the error message is like this.


			
SIGSEGV 11* segmentation violation
si_signo [11]: SIGSEGV 11* segmentation violation
si_errno [0]: Error 0
si_code [1]: SEGV_MAPERR [addr: 0x128]

User context info:
pc = 0xfa399f0 (SignalError = 0x4042d30)
sp = 0x109daa90, ra = 0x400d0e0
Abort


I still don't what makes this problem. I made the java method that status checker calls static and tried the same thing, still didn't work out.


Please HELP ME !!!!

   <<Less
About | Sitemap | Contact