comp.lang.ada
 help / color / mirror / Atom feed
* Help: Problem with JGnat
@ 2002-08-02  2:46 Bin Chen
  2002-08-02  8:04 ` Dr. Michael Paus
  0 siblings, 1 reply; 7+ messages in thread
From: Bin Chen @ 2002-08-02  2:46 UTC (permalink / raw)


Hi,

I used jgnat compile the following Ada program to Java bytecode, it was OK,
but when I ran the .class file, it always threw the following exception.
Could you give me any feedback?

Thank you.

Bin Chen


Exception:

Exception in thread "main" java.lang.IllegalMonitorStateException
        at
jgnat.adalib.system$task_primitives$operations.write_lock__2(s-taprop.adb:22
9)
        at
jgnat.adalib.system$task_primitives$operations.lock_all_tasks_list(s-taprop.
adb:771)
        at
jgnat.adalib.system$task_primitives$operations.enter_task(s-taprop.adb:373)
        at
jgnat.adalib.system$task_primitives$operations.initialize(s-taprop.adb:834)
        at jgnat.adalib.system$tasking._elabb(s-taskin.adb:186)
        at ada_main.adainit(b~main.adb:89)
        at main.main(main.adb)

Sources:

--Pack_Factorial.ads
package Pack_Factorial is
  task type Task_Factorial is --Specification
    entry Start( F:in Positive ); --Rendezvous
    entry Finish( Result:out Positive ); --Rendezvous
  end Task_Factorial;
end Pack_Factorial;

--Pack_Factorial.adb
package body Pack_Factorial is
  task body Task_Factorial is --Implementation
    Factorial : Positive;
    Answer : Positive := 1;
  begin
    accept Start( F:in Positive ) do --Factorial
      Factorial := F;
    end Start;
    for I in 2 .. Factorial loop --Calculate
      Answer := Answer * I;
    end loop;
    accept Finish( Result:out Positive ) do --Return answer
      Result := Answer;
    end Finish;
  end Task_Factorial;
end Pack_Factorial;

--main.adb
with Ada.Text_Io, Ada.Integer_Text_Io, Pack_Factorial;
use Ada.Text_Io, Ada.Integer_Text_Io, Pack_Factorial;
procedure main is
 Thread_1 : Task_Factorial;
 Factorial: Positive;
begin
 Thread_1.Start(5); --Start factorial calculation
 Put("Factorial 5 is ");
 Thread_1.Finish( Factorial ); --Obtain result
 Put( Factorial ); New_Line;
end Main;






^ permalink raw reply	[flat|nested] 7+ messages in thread

* Help: Problem with JGnat
@ 2002-08-02  4:35 Bin Chen
  0 siblings, 0 replies; 7+ messages in thread
From: Bin Chen @ 2002-08-02  4:35 UTC (permalink / raw)


Hi,

I used jgnat compile the following Ada program to Java bytecode, it was OK,
but when I ran the .class file, it always threw the following exception.
Could you give me any feedback?

Thank you.

Bin Chen


Exception:

Exception in thread "main" java.lang.IllegalMonitorStateException
        at
jgnat.adalib.system$task_primitives$operations.write_lock__2(s-taprop.adb:22
9)
        at
jgnat.adalib.system$task_primitives$operations.lock_all_tasks_list(s-taprop.
adb:771)
        at
jgnat.adalib.system$task_primitives$operations.enter_task(s-taprop.adb:373)
        at
jgnat.adalib.system$task_primitives$operations.initialize(s-taprop.adb:834)
        at jgnat.adalib.system$tasking._elabb(s-taskin.adb:186)
        at ada_main.adainit(b~main.adb:89)
        at main.main(main.adb)

Sources:

--Pack_Factorial.ads
package Pack_Factorial is
  task type Task_Factorial is --Specification
    entry Start( F:in Positive ); --Rendezvous
    entry Finish( Result:out Positive ); --Rendezvous
  end Task_Factorial;
end Pack_Factorial;

--Pack_Factorial.adb
package body Pack_Factorial is
  task body Task_Factorial is --Implementation
    Factorial : Positive;
    Answer : Positive := 1;
  begin
    accept Start( F:in Positive ) do --Factorial
      Factorial := F;
    end Start;
    for I in 2 .. Factorial loop --Calculate
      Answer := Answer * I;
    end loop;
    accept Finish( Result:out Positive ) do --Return answer
      Result := Answer;
    end Finish;
  end Task_Factorial;
end Pack_Factorial;

--main.adb
with Ada.Text_Io, Ada.Integer_Text_Io, Pack_Factorial;
use Ada.Text_Io, Ada.Integer_Text_Io, Pack_Factorial;
procedure main is
 Thread_1 : Task_Factorial;
 Factorial: Positive;
begin
 Thread_1.Start(5); --Start factorial calculation
 Put("Factorial 5 is ");
 Thread_1.Finish( Factorial ); --Obtain result
 Put( Factorial ); New_Line;
end Main;








^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Help: Problem with JGnat
  2002-08-02  2:46 Bin Chen
@ 2002-08-02  8:04 ` Dr. Michael Paus
  2002-08-02 12:29   ` Marc A. Criley
  0 siblings, 1 reply; 7+ messages in thread
From: Dr. Michael Paus @ 2002-08-02  8:04 UTC (permalink / raw)


Bin Chen wrote:
> Hi,
> 
> I used jgnat compile the following Ada program to Java bytecode, it was OK,
> but when I ran the .class file, it always threw the following exception.
> Could you give me any feedback?

Which version of Java are you using? JGNAT does not work on recent Java
distributions anymore unless there is  a newer version than the one I have.
(1.1p). See also the comment on http://www.gnuada.org/rpms313p.html about
JGNAT.

Michael




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Help: Problem with JGnat
  2002-08-02  8:04 ` Dr. Michael Paus
@ 2002-08-02 12:29   ` Marc A. Criley
  2002-08-02 16:04     ` Bin Chen
  2002-08-02 18:37     ` Robert Dewar
  0 siblings, 2 replies; 7+ messages in thread
From: Marc A. Criley @ 2002-08-02 12:29 UTC (permalink / raw)


"Dr. Michael Paus" wrote:
> 
> Bin Chen wrote:
> > Hi,
> >
> > I used jgnat compile the following Ada program to Java bytecode, it was OK,
> > but when I ran the .class file, it always threw the following exception.
> > Could you give me any feedback?
> 
> Which version of Java are you using? JGNAT does not work on recent Java
> distributions anymore unless there is  a newer version than the one I have.
> (1.1p). See also the comment on http://www.gnuada.org/rpms313p.html about
> JGNAT.

Yep, JGNAT 1.1p works (mostly) fine with with JDK 1.2.2, but tasking is
broken when used with JDK 1.3.  And I've not tried it with JDK 1.4, but
based on what I've seen, I think the likelihood of it working very well
is low.

I've heard that the last supported version of JGNAT worked okay with
1.3, but I know of no access to that version.  In addition, ACT has
terminated support for JGNAT  :-(  Business decision on their part, for
which I can't blame them--their intent is to make a profit, after
all--but I really liked the concept and had been heavily using the
public version.  Oh well.

Marc A. Criley



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Help: Problem with JGnat
  2002-08-02 12:29   ` Marc A. Criley
@ 2002-08-02 16:04     ` Bin Chen
  2002-08-02 18:55       ` David Marceau
  2002-08-02 18:37     ` Robert Dewar
  1 sibling, 1 reply; 7+ messages in thread
From: Bin Chen @ 2002-08-02 16:04 UTC (permalink / raw)


Thank you very much.

Bin


"Marc A. Criley" <mcq95@earthlink.net> wrote in message
news:3D4A7C39.2AF0BA8@earthlink.net...
> "Dr. Michael Paus" wrote:
> >
> > Bin Chen wrote:
> > > Hi,
> > >
> > > I used jgnat compile the following Ada program to Java bytecode, it
was OK,
> > > but when I ran the .class file, it always threw the following
exception.
> > > Could you give me any feedback?
> >
> > Which version of Java are you using? JGNAT does not work on recent Java
> > distributions anymore unless there is  a newer version than the one I
have.
> > (1.1p). See also the comment on http://www.gnuada.org/rpms313p.html
about
> > JGNAT.
>
> Yep, JGNAT 1.1p works (mostly) fine with with JDK 1.2.2, but tasking is
> broken when used with JDK 1.3.  And I've not tried it with JDK 1.4, but
> based on what I've seen, I think the likelihood of it working very well
> is low.
>
> I've heard that the last supported version of JGNAT worked okay with
> 1.3, but I know of no access to that version.  In addition, ACT has
> terminated support for JGNAT  :-(  Business decision on their part, for
> which I can't blame them--their intent is to make a profit, after
> all--but I really liked the concept and had been heavily using the
> public version.  Oh well.
>
> Marc A. Criley





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Help: Problem with JGnat
  2002-08-02 12:29   ` Marc A. Criley
  2002-08-02 16:04     ` Bin Chen
@ 2002-08-02 18:37     ` Robert Dewar
  1 sibling, 0 replies; 7+ messages in thread
From: Robert Dewar @ 2002-08-02 18:37 UTC (permalink / raw)


"Marc A. Criley" <mcq95@earthlink.net> wrote in message news:<3D4A7C39.2AF0BA8@earthlink.net>...

> I've heard that the last supported version of JGNAT worked okay with
> 1.3, but I know of no access to that version.  In addition, ACT has
> terminated support for JGNAT  :-(  Business decision on their part, for
> which I can't blame them--their intent is to make a profit, after
> all--but I really liked the concept and had been heavily using the
> public version.  Oh well.

Not so much an issue of making a profit, as one of not losing lots of 
$$$ on this product. Unfortunately there was very little commercial
interest.

Robert Dewar
Ada Core Technologies



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Help: Problem with JGnat
  2002-08-02 16:04     ` Bin Chen
@ 2002-08-02 18:55       ` David Marceau
  0 siblings, 0 replies; 7+ messages in thread
From: David Marceau @ 2002-08-02 18:55 UTC (permalink / raw)


What about trying to turn the JIT compiler off? There's a
switch/environment variable for this in the jdk docs.
That's how it could work with jdk 1.3.  You have to turn the jit
compiler off.  In this mode it's as if it was running the jdk 1.2.2
compiler :)
It's also good to do this when debugging just java IMHO.

Bin Chen wrote:
> 
> Thank you very much.
> 
> Bin
> 
> "Marc A. Criley" <mcq95@earthlink.net> wrote in message
> news:3D4A7C39.2AF0BA8@earthlink.net...
> > "Dr. Michael Paus" wrote:
> > >
> > > Bin Chen wrote:
> > > > Hi,
> > > >
> > > > I used jgnat compile the following Ada program to Java bytecode, it
> was OK,
> > > > but when I ran the .class file, it always threw the following
> exception.
> > > > Could you give me any feedback?
> > >
> > > Which version of Java are you using? JGNAT does not work on recent Java
> > > distributions anymore unless there is  a newer version than the one I
> have.
> > > (1.1p). See also the comment on http://www.gnuada.org/rpms313p.html
> about
> > > JGNAT.
> >
> > Yep, JGNAT 1.1p works (mostly) fine with with JDK 1.2.2, but tasking is
> > broken when used with JDK 1.3.  And I've not tried it with JDK 1.4, but
Hmmm. I remember looking at the jgnat sources and IMHO ACT mapped every
ada task to a java Thread class and not the Runnable Class.
In the HPCJ(High Performance Computing with Java) book, the author
mentioned a flaw with Thread class.
The Thread once started and then after finishing the contents of the
run() would pretend to be garbage collected but it's not.  Which means
if you run 300000 Thread.run()'s you're bound to have a memory/resource
leak issue since the Thread objects are really only garbage collected
when the entire main() process is exited.  This HPCJ book suggests using
a Thread pool which are expected to exist throughout the process
lifetime.  As soon as one Thread is terminated, you may assign another
Runnable to it hence saving resources.i.e Thread pool of say 10000
Threads.  Instantiate and Thread.setTaskRunnable(new adaRunnable(XXX));
and then thisthread.start();  In this manner, it could be a bit more
resilient to memory/resource issues :)  Runnable objects are garbage
collected as expected. Thread objects are not.  I wonder if this has
something to do with the jgnat Tasking being broken?

Cheers,
David Marceau



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-08-02 18:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-02  4:35 Help: Problem with JGnat Bin Chen
  -- strict thread matches above, loose matches on Subject: below --
2002-08-02  2:46 Bin Chen
2002-08-02  8:04 ` Dr. Michael Paus
2002-08-02 12:29   ` Marc A. Criley
2002-08-02 16:04     ` Bin Chen
2002-08-02 18:55       ` David Marceau
2002-08-02 18:37     ` Robert Dewar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox