I don't *NEED* to, I realize there are better ways to compute Fibonacci,
if computing Fibonacci was all I cared about. I just *WANT* to because I
am benchmarking some multithreaded implementations, Java included, and
Fibonacci, although a contrived example, gives a good indication of thread
overhead because there is very little computation involved in each thread.
Could a possible cause be the max threads limit on the machine being
reached? I have a similar problem with P-Threads, however not until a
much higher instance of Fib than 6.
- Pat
On Wed, 27 Jan 1999, Vittorio Ballestra wrote:
> What I funny rabbit it is !?!
> Why do you need to fork a process for every recursive step ?
>
> > -----Original Message-----
> > From: Patrick W. O'Neill [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, January 26, 1999 19:42
> > To: Michael Sinz
> > Cc: [EMAIL PROTECTED]
> > Subject: Problem
> >
> >
> > I apologize if this is the incorrect place to send this, I tried
> > submitting a bug report but I don't know if it got through, and it is
> > important that I resolve this ASAP.
> >
> > I have a problem with JDK1.1.7-v1a running green threads. I am running
> > basic fibonacci code, using the recursive algorithm and implemented with
> > threads. This code runs without incident on the Solaris JDK. However,
> > when I try to run it using the Blackdown port, it works fine up to fib 5,
> > but when I run fib 6, I get a seg fault. I am running this on a Debian
> > 2.0 system with glibc. I have a similar problem with n-queens code, it
> > runs fine on Solaris, but on Linux problems arise above an 8x8 board.
> >
> > I you had any ideas as to why this happens I would greatly appreciate
> > them. Thanks.
> >
> >
> > - Pat
> >
> >
> > --------- Code -------------
> >
> > import java.util.*;
> >
> > public class java_fib extends Thread
> > {
> > private int fib;
> >
> > java_fib(int number) {
> > fib = number;
> > }
> >
> > public void run() {
> > if( (fib==0) || (fib == 1)) {
> > fib = fib;
> > }
> >
> > else {
> > java_fib java_fib_thread_1 = new java_fib(fib - 1);
> > java_fib java_fib_thread_2 = new java_fib(fib - 2);
> >
> > java_fib_thread_1.start();
> > java_fib_thread_2.start();
> >
> > try {
> > java_fib_thread_1.join();
> > java_fib_thread_2.join();
> > fib = java_fib_thread_1.get_fib() +
> > java_fib_thread_2.get_fib();
> > }
> > catch(InterruptedException e){
> > e.printStackTrace();
> > }
> > }
> > }
> >
> > private int get_fib() {
> > return fib;
> > }
> >
> >
> > public static void main(String arg[]) {
> > java_fib fib;
> > int number;
> > number = new Integer(arg[0]).intValue();
> > fib = new java_fib(number);
> > Date now;
> > Date then = new Date();
> > fib.start();
> >
> > try {
> > fib.join();
> > now = new Date();
> > System.out.println("The total execution time is " +
> > ((now.getTime() - then.getTime())) + "ms.");
> > System.out.println("The fibonacci for " + number + " is: " +
> > fib.get_fib());
> > }
> > catch(InterruptedException e) {
> > e.printStackTrace();
> > }
> > }
> > }
> >
>