comp.lang.ada
 help / color / mirror / Atom feed
* Using Xt intrinsics with Ada?
@ 2001-01-31 15:55 Jürgen Grigat
  2001-01-31 18:14 ` Stephen Leake
                   ` (4 more replies)
  0 siblings, 5 replies; 20+ messages in thread
From: Jürgen Grigat @ 2001-01-31 15:55 UTC (permalink / raw)


Hi,

we are developing a program in Ada that has connections to other processes by
sockets. The calls are done in Ada by using interfaces to C library functions.
In order to avoid polling we wonder if we can use the event mechanism of X
Toolkit  Intrinsics. So we created a task which is calling a C-routine that
itself calls XtAppMainLoop. The main program is an Ada routine.
From the functional point of view this seems to work. But we recognize a heavy
CPU load even there is no traffic at the connection.

Has anyone experience in using X Toolkit events in Ada tasking programs?

Thanks for any hints.

J�rgen








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

* Re: Using Xt intrinsics with Ada?
  2001-01-31 15:55 Using Xt intrinsics with Ada? Jürgen Grigat
@ 2001-01-31 18:14 ` Stephen Leake
  2001-02-02  9:58   ` Juergen Fischer
  2001-01-31 19:19 ` Ted Dennison
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 20+ messages in thread
From: Stephen Leake @ 2001-01-31 18:14 UTC (permalink / raw)


J�rgen Grigat <juergen.grigat@avitech.de> writes:

> Hi,
> 
> we are developing a program in Ada that has connections to other processes by
> sockets. The calls are done in Ada by using interfaces to C library functions.
> In order to avoid polling we wonder if we can use the event mechanism of X
> Toolkit  Intrinsics. 

This seems an awkward approach. You are using a windowing system to
get tasking; just use Ada tasking!

Allocate one task for each socket connection, that does blocking reads
and writes to the socket. Then have a central task that rendezvous
with the per-socket tasks.

You will need a runtime that blocks at the task level, not the process level.

> So we created a task which is calling a C-routine that itself calls
> XtAppMainLoop. The main program is an Ada routine. From the
> functional point of view this seems to work. But we recognize a
> heavy CPU load even there is no traffic at the connection.

I'm not sure, but I would bet that XtAppMainLoop is polling, looking
for events! So you haven't accomplished anything.

> Has anyone experience in using X Toolkit events in Ada tasking
> programs?
> 
> Thanks for any hints.
> 
> J�rgen

-- 
-- Stephe



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

* Re: Using Xt intrinsics with Ada?
  2001-01-31 15:55 Using Xt intrinsics with Ada? Jürgen Grigat
  2001-01-31 18:14 ` Stephen Leake
@ 2001-01-31 19:19 ` Ted Dennison
  2001-01-31 21:07   ` Ted Dennison
  2001-01-31 19:42 ` Kevin Kronmiller
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 20+ messages in thread
From: Ted Dennison @ 2001-01-31 19:19 UTC (permalink / raw)


In article <3A78357A.2BD8C0B1@avitech.de>,
  =?iso-8859-1?Q?J=FCrgen?= Grigat <juergen.grigat@avitech.de> wrote:

> sockets. The calls are done in Ada by using interfaces to C library
> functions. In order to avoid polling we wonder if we can use the event
>  mechanism of X Toolkit  Intrinsics. So we created a task which is
> calling a C-routine that itself calls XtAppMainLoop. The main program
> is an Ada routine. From the functional point of view this seems to
> work. But we recognize a heavy CPU load even there is no traffic at
> the connection.

I'm missing something here. XtAppMainLoop never returns to the caller.
How exactly are you planning on getting the sockets serviced? Are you
saying that you hooked a socket servicing routine into an X event
somehow? If so, exacty how?

Have you tried doing this exact same thing in C-only code? Sometimes I
find it useful to remove that particular variable when I'm trying to
test something new.

--
T.E.D.

http://www.telepath.com/~dennison/Ted/TED.html


Sent via Deja.com
http://www.deja.com/



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

* Re: Using Xt intrinsics with Ada?
  2001-01-31 15:55 Using Xt intrinsics with Ada? Jürgen Grigat
  2001-01-31 18:14 ` Stephen Leake
  2001-01-31 19:19 ` Ted Dennison
@ 2001-01-31 19:42 ` Kevin Kronmiller
  2001-02-01 11:55 ` Tarjei T. Jensen
  2001-02-02 16:08 ` Des Walker
  4 siblings, 0 replies; 20+ messages in thread
From: Kevin Kronmiller @ 2001-01-31 19:42 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 892 bytes --]



Sounds like a job for select() unless I misunderstand your problem.

Kevin Kronmiller

In article <3A78357A.2BD8C0B1@avitech.de>,
  =?iso-8859-1?Q?J=FCrgen?= Grigat <juergen.grigat@avitech.de> wrote:
> Hi,
>
> we are developing a program in Ada that has connections to other
processes by
> sockets. The calls are done in Ada by using interfaces to C library
functions.
> In order to avoid polling we wonder if we can use the event mechanism
of X
> Toolkit  Intrinsics. So we created a task which is calling a C-
routine that
> itself calls XtAppMainLoop. The main program is an Ada routine.
> From the functional point of view this seems to work. But we
recognize a heavy
> CPU load even there is no traffic at the connection.
>
> Has anyone experience in using X Toolkit events in Ada tasking
programs?
>
> Thanks for any hints.
>
> J�rgen
>
>


Sent via Deja.com
http://www.deja.com/



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

* Re: Using Xt intrinsics with Ada?
  2001-01-31 19:19 ` Ted Dennison
@ 2001-01-31 21:07   ` Ted Dennison
  2001-01-31 21:40     ` Mario Klebsch
  0 siblings, 1 reply; 20+ messages in thread
From: Ted Dennison @ 2001-01-31 21:07 UTC (permalink / raw)


In article <959oeu$s8g$1@nnrp1.deja.com>,
  Ted Dennison <dennison@telepath.com> wrote:

> I'm missing something here. XtAppMainLoop never returns to the caller.
> How exactly are you planning on getting the sockets serviced? Are you
> saying that you hooked a socket servicing routine into an X event
> somehow? If so, exacty how?


Ahh. Can I assume that you are using XtAppAddInput to attempt to get it
to process incomming data on a socket as an X input?

In that case, I'd definitely try to get this working in C before Adding
Ada to the mix. If you get the same error in C (most likely you will),
you can remove "Ada" from your question and the newsgroups list and ask
again. I don't like to put the word "Ada" anywhere near an OS library
question, as lots of folks seem convinced that all OS libraries have
some super-special code that scans binaries to magicly figure out what
source language they were compiled from, so that they can misbehave if
that language wasn't C. :-)

One caveat that caught my eye in the docs for XtAppAddInput was the
following:

---------------------
...you should be careful not to close the end of the socket that is
waiting before exiting XtAppMainLoop().  If you do this, you will get an
infinite loop, in which the callback is called repeatedly, while the
Intrinsics wait for an EOF to be read.
-----------------------

I wouldn't be shocked if this, or a similar problem, was the cause of
your troubles.

--
T.E.D.

http://www.telepath.com/~dennison/Ted/TED.html


Sent via Deja.com
http://www.deja.com/



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

* Re: Using Xt intrinsics with Ada?
  2001-01-31 21:07   ` Ted Dennison
@ 2001-01-31 21:40     ` Mario Klebsch
  2001-02-02 16:26       ` Juergen Fischer
  0 siblings, 1 reply; 20+ messages in thread
From: Mario Klebsch @ 2001-01-31 21:40 UTC (permalink / raw)


Ted Dennison <dennison@telepath.com> writes:

>One caveat that caught my eye in the docs for XtAppAddInput was the
>following:

>---------------------
>...you should be careful not to close the end of the socket that is
>waiting before exiting XtAppMainLoop().  If you do this, you will get an
>infinite loop, in which the callback is called repeatedly, while the
>Intrinsics wait for an EOF to be read.
>-----------------------

>I wouldn't be shocked if this, or a similar problem, was the cause of
>your troubles.

It should be sufficient to XtRemoveInput() the descriptor prior to
closing it.

73, Mario
-- 
Mario Klebsch						mario@klebsch.de
PGP-Key available at http://www.klebsch.de/public.key
Fingerprint DSS: EE7C DBCC D9C8 5DC1 D4DB  1483 30CE 9FB2 A047 9CE0
 Diffie-Hellman: D447 4ED6 8A10 2C65 C5E5  8B98 9464 53FF 9382 F518



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

* Re: Using Xt intrinsics with Ada?
  2001-01-31 15:55 Using Xt intrinsics with Ada? Jürgen Grigat
                   ` (2 preceding siblings ...)
  2001-01-31 19:42 ` Kevin Kronmiller
@ 2001-02-01 11:55 ` Tarjei T. Jensen
  2001-02-02 16:08 ` Des Walker
  4 siblings, 0 replies; 20+ messages in thread
From: Tarjei T. Jensen @ 2001-02-01 11:55 UTC (permalink / raw)



J�rgen Grigat wrote in message <3A78357A.2BD8C0B1@avitech.de>...
>Hi,
>
>we are developing a program in Ada that has connections to other processes by
>sockets. The calls are done in Ada by using interfaces to C library functions.
>In order to avoid polling we wonder if we can use the event mechanism of X
>Toolkit  Intrinsics. So we created a task which is calling a C-routine that
>itself calls XtAppMainLoop. The main program is an Ada routine.
>From the functional point of view this seems to work. But we recognize a heavy
>CPU load even there is no traffic at the connection.
>
>Has anyone experience in using X Toolkit events in Ada tasking programs?

As someone else said: This is a job for select() and friends. See W. Richard
Stevens "Unix network programming" 2nd edition for how to do this and what
options are available. You should have no problem doing this in Ada. BTW. are
you sure that this cannot be done by using the distributed annex in Ada? Gnat
is supposed to have all the distributed annex stuff implemented.


Greetings,






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

* Re: Using Xt intrinsics with Ada?
  2001-01-31 18:14 ` Stephen Leake
@ 2001-02-02  9:58   ` Juergen Fischer
  2001-02-02 12:00     ` Jeff Creem
                       ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: Juergen Fischer @ 2001-02-02  9:58 UTC (permalink / raw)
  To: Stephen Leake

[-- Attachment #1: Type: text/plain, Size: 1696 bytes --]

Hi,

the problem is that we don't have the runtime that blocks on the task level but only
on the process level.
Therefore we have to use non blocking sockets. The XtAppMainLoop does really poll,
but from other C programs we know that it doesn't take much CPU load. So we suppose
that the CPU load is caused by
Ada tasking in combination with the XtAppMainLoop.

Who has already used XtAppMainLoop within an Ada program?

Juergen

Stephen Leake wrote:

> J�rgen Grigat <juergen.grigat@avitech.de> writes:
>
> > Hi,
> >
> > we are developing a program in Ada that has connections to other processes by
> > sockets. The calls are done in Ada by using interfaces to C library functions.
> > In order to avoid polling we wonder if we can use the event mechanism of X
> > Toolkit  Intrinsics.
>
> This seems an awkward approach. You are using a windowing system to
> get tasking; just use Ada tasking!
>
> Allocate one task for each socket connection, that does blocking reads
> and writes to the socket. Then have a central task that rendezvous
> with the per-socket tasks.
>
> You will need a runtime that blocks at the task level, not the process level.
>
> > So we created a task which is calling a C-routine that itself calls
> > XtAppMainLoop. The main program is an Ada routine. From the
> > functional point of view this seems to work. But we recognize a
> > heavy CPU load even there is no traffic at the connection.
>
> I'm not sure, but I would bet that XtAppMainLoop is polling, looking
> for events! So you haven't accomplished anything.
>
> > Has anyone experience in using X Toolkit events in Ada tasking
> > programs?
> >
> > Thanks for any hints.
> >
> > J�rgen
>
> --
> -- Stephe

[-- Attachment #2: Card for Juergen Fischer --]
[-- Type: text/x-vcard, Size: 462 bytes --]

begin:vcard 
n:Fischer;Juergen
tel;pager:+49.(0)168.6957035
tel;cell:+49.(0)170.1630414
tel;fax:+49.(0)7541.282-299
tel;work:+49.(0)7541.282-387
x-mozilla-html:TRUE
url:http://www.avitech.de
org:Aviation Management Technologies GmbH;Software Development
adr:;;Bahnhofplatz 1;Friedrichshafen;Baden-Wuerttemberg;88004;Germany
version:2.1
email;internet:Juergen.Fischer@avitech.de
title:Dr. rer. nat. Dipl.-Math.
x-mozilla-cpt:;-25792
fn:Fischer, Juergen
end:vcard

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

* Re: Using Xt intrinsics with Ada?
  2001-02-02  9:58   ` Juergen Fischer
@ 2001-02-02 12:00     ` Jeff Creem
  2001-02-02 15:02     ` Ted Dennison
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 20+ messages in thread
From: Jeff Creem @ 2001-02-02 12:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2377 bytes --]

Is this existing legacy code that you are trying to update or a new
application?
In either case, does you compiler have an option to choose a different run
time (GNAT and Rational
Apex typically do depending on the platform).

It is certainly possible to get things to work with the process level
blocking tasks but for certain classes of
problems it does make your life more difficult..(Note that this may not be
one of them. I don't think we have
enough info to tell yet)..



"Juergen Fischer" <juergen.fischer@avitech.de> wrote in message
news:3A7A84C3.2486A6CF@avitech.de...
> Hi,
>
> the problem is that we don't have the runtime that blocks on the task
level but only
> on the process level.
> Therefore we have to use non blocking sockets. The XtAppMainLoop does
really poll,
> but from other C programs we know that it doesn't take much CPU load. So
we suppose
> that the CPU load is caused by
> Ada tasking in combination with the XtAppMainLoop.
>
> Who has already used XtAppMainLoop within an Ada program?
>
> Juergen
>
> Stephen Leake wrote:
>
> > J�rgen Grigat <juergen.grigat@avitech.de> writes:
> >
> > > Hi,
> > >
> > > we are developing a program in Ada that has connections to other
processes by
> > > sockets. The calls are done in Ada by using interfaces to C library
functions.
> > > In order to avoid polling we wonder if we can use the event mechanism
of X
> > > Toolkit  Intrinsics.
> >
> > This seems an awkward approach. You are using a windowing system to
> > get tasking; just use Ada tasking!
> >
> > Allocate one task for each socket connection, that does blocking reads
> > and writes to the socket. Then have a central task that rendezvous
> > with the per-socket tasks.
> >
> > You will need a runtime that blocks at the task level, not the process
level.
> >
> > > So we created a task which is calling a C-routine that itself calls
> > > XtAppMainLoop. The main program is an Ada routine. From the
> > > functional point of view this seems to work. But we recognize a
> > > heavy CPU load even there is no traffic at the connection.
> >
> > I'm not sure, but I would bet that XtAppMainLoop is polling, looking
> > for events! So you haven't accomplished anything.
> >
> > > Has anyone experience in using X Toolkit events in Ada tasking
> > > programs?
> > >
> > > Thanks for any hints.
> > >
> > > J�rgen
> >
> > --
> > -- Stephe
>





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

* Re: Using Xt intrinsics with Ada?
  2001-02-02  9:58   ` Juergen Fischer
  2001-02-02 12:00     ` Jeff Creem
@ 2001-02-02 15:02     ` Ted Dennison
  2001-02-02 15:43       ` Juergen Fischer
  2001-02-02 15:06     ` Stephen Leake
  2001-02-02 15:21     ` Robert Dewar
  3 siblings, 1 reply; 20+ messages in thread
From: Ted Dennison @ 2001-02-02 15:02 UTC (permalink / raw)


In article <3A7A84C3.2486A6CF@avitech.de>,
  Juergen Fischer <juergen.fischer@avitech.de> wrote:

> but from other C programs we know that it doesn't take much CPU load.
> So we suppose that the CPU load is caused by
> Ada tasking in combination with the XtAppMainLoop.

That doesn't make much sense to me. Furthermore, it sounds a lot the the
"it must be Ada's fault" knee-jerk reactions I always get when I mention
Ada in the context of a problem to OS library people.

But in any event, it should be trivial to check this assumption. Just
replace your Ada "main" with a C "main", and see what happens. I'll bet
you a virtual beer that you get the exact same behavior. :-)


> Who has already used XtAppMainLoop within an Ada program?

I have. Did it on the old SunOS using a VADS compiler, and once on the
Harris Nighthawk. The only real problem I can remember was that we had
to make sure that only the XtAppMainLoop task made any X calls (and I
think there are X bindings available that remove that restriction).

--
T.E.D.

http://www.telepath.com/~dennison/Ted/TED.html


Sent via Deja.com
http://www.deja.com/



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

* Re: Using Xt intrinsics with Ada?
  2001-02-02  9:58   ` Juergen Fischer
  2001-02-02 12:00     ` Jeff Creem
  2001-02-02 15:02     ` Ted Dennison
@ 2001-02-02 15:06     ` Stephen Leake
  2001-02-02 15:48       ` Juergen Fischer
  2001-02-02 15:21     ` Robert Dewar
  3 siblings, 1 reply; 20+ messages in thread
From: Stephen Leake @ 2001-02-02 15:06 UTC (permalink / raw)


Juergen Fischer <juergen.fischer@avitech.de> writes:

> Hi,
> 
> the problem is that we don't have the runtime that blocks on the task
> level but only on the process level.
> Therefore we have to use non blocking sockets. The XtAppMainLoop does
> really poll,
> but from other C programs we know that it doesn't take much CPU load.
> So we suppose that the CPU load is caused by
> Ada tasking in combination with the XtAppMainLoop.

Ok, now you realize that you _cannot_ avoid polling, because your OS
does not provide task-level blocking sockets. Bringing in X windows
stuff cannot change that.

You can either get threads and sockets libraries that provide this
functionality, or convert your program to a multi-process one,
possibly using Ada partitions. Which OS and compiler are you using?

Or perhaps you can design an acceptable polling solution; it appears
that you hoped the XtAppMainLoop would be such a thing. You are more
likely to be successful if you code the polling directly. Perhaps you
could use the source for XtAppMainLoop as a guide.

-- 
-- Stephe



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

* Re: Using Xt intrinsics with Ada?
  2001-02-02  9:58   ` Juergen Fischer
                       ` (2 preceding siblings ...)
  2001-02-02 15:06     ` Stephen Leake
@ 2001-02-02 15:21     ` Robert Dewar
  3 siblings, 0 replies; 20+ messages in thread
From: Robert Dewar @ 2001-02-02 15:21 UTC (permalink / raw)


In article <3A7A84C3.2486A6CF@avitech.de>,
  Juergen Fischer <juergen.fischer@avitech.de> wrote:
> This is a multi-part message in MIME format.
> --------------43E2B9E3243810F15EDAE55F
> Content-Type: text/plain; charset=iso-8859-1
> Content-Transfer-Encoding: 8bit
>
> Hi,
>
> the problem is that we don't have the runtime that blocks on
>the task level but only
> on the process level.

That seems a crippling restriction in this environment, why
not fix this problem directly?


Sent via Deja.com
http://www.deja.com/



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

* Re: Using Xt intrinsics with Ada?
  2001-02-02 15:02     ` Ted Dennison
@ 2001-02-02 15:43       ` Juergen Fischer
  2001-02-02 19:30         ` Ted Dennison
  0 siblings, 1 reply; 20+ messages in thread
From: Juergen Fischer @ 2001-02-02 15:43 UTC (permalink / raw)
  To: Ted Dennison

[-- Attachment #1: Type: text/plain, Size: 1859 bytes --]

Hi,

Ted Dennison wrote:

> In article <3A7A84C3.2486A6CF@avitech.de>,
>   Juergen Fischer <juergen.fischer@avitech.de> wrote:
>
> > but from other C programs we know that it doesn't take much CPU load.
> > So we suppose that the CPU load is caused by
> > Ada tasking in combination with the XtAppMainLoop.
>
> That doesn't make much sense to me. Furthermore, it sounds a lot the the
> "it must be Ada's fault" knee-jerk reactions I always get when I mention
> Ada in the context of a problem to OS library people.

Sorry about that, I am only looking for a solution and it was not my
intention
to polemize against Ada.

>
>
> But in any event, it should be trivial to check this assumption. Just
> replace your Ada "main" with a C "main", and see what happens. I'll bet
> you a virtual beer that you get the exact same behavior. :-)

I have reduced the Ada "main" to the start of the XtAppMainLoop. With all
other tasks
switched off  there is no CPU load (same behaviour as in a C program). With
all other
tasks switched on but XtAppMainLoop not started the process does not consume
CPU,
either. Only the combination of XtAppMainLoop and the other application
tasks leads to
CPU load although the application, after initialization, is in a wait state.

I compiled the Ada Sources with ObjectAda 7.1.2. The OS is HP_UX 10.20.

Juergen

>
>
> > Who has already used XtAppMainLoop within an Ada program?
>
> I have. Did it on the old SunOS using a VADS compiler, and once on the
> Harris Nighthawk. The only real problem I can remember was that we had
> to make sure that only the XtAppMainLoop task made any X calls (and I
> think there are X bindings available that remove that restriction).

In my application no other task makes any X calls.

>
>
> --
> T.E.D.
>
> http://www.telepath.com/~dennison/Ted/TED.html
>
> Sent via Deja.com
> http://www.deja.com/

[-- Attachment #2: Card for Juergen Fischer --]
[-- Type: text/x-vcard, Size: 462 bytes --]

begin:vcard 
n:Fischer;Juergen
tel;pager:+49.(0)168.6957035
tel;cell:+49.(0)170.1630414
tel;fax:+49.(0)7541.282-299
tel;work:+49.(0)7541.282-387
x-mozilla-html:TRUE
url:http://www.avitech.de
org:Aviation Management Technologies GmbH;Software Development
adr:;;Bahnhofplatz 1;Friedrichshafen;Baden-Wuerttemberg;88004;Germany
version:2.1
email;internet:Juergen.Fischer@avitech.de
title:Dr. rer. nat. Dipl.-Math.
x-mozilla-cpt:;-25792
fn:Fischer, Juergen
end:vcard

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

* Re: Using Xt intrinsics with Ada?
  2001-02-02 15:06     ` Stephen Leake
@ 2001-02-02 15:48       ` Juergen Fischer
  2001-02-05 15:06         ` Stephen Leake
  0 siblings, 1 reply; 20+ messages in thread
From: Juergen Fischer @ 2001-02-02 15:48 UTC (permalink / raw)
  To: Stephen Leake

[-- Attachment #1: Type: text/plain, Size: 1366 bytes --]

Hi,

Stephen Leake wrote:

> Juergen Fischer <juergen.fischer@avitech.de> writes:
>
> > Hi,
> >
> > the problem is that we don't have the runtime that blocks on the task
> > level but only on the process level.
> > Therefore we have to use non blocking sockets. The XtAppMainLoop does
> > really poll,
> > but from other C programs we know that it doesn't take much CPU load.
> > So we suppose that the CPU load is caused by
> > Ada tasking in combination with the XtAppMainLoop.
>
> Ok, now you realize that you _cannot_ avoid polling, because your OS
> does not provide task-level blocking sockets. Bringing in X windows
> stuff cannot change that.

I had realized this before, but from C applications I know that socket
polling
by means of XtAppMainLoop costs less CPU load than a directly coded polling

solution.

>
>
> You can either get threads and sockets libraries that provide this
> functionality, or convert your program to a multi-process one,
> possibly using Ada partitions. Which OS and compiler are you using?

HP_UX 10.20 and Aonix ObjectAda 7.1.2

Juergen

>
>
> Or perhaps you can design an acceptable polling solution; it appears
> that you hoped the XtAppMainLoop would be such a thing. You are more
> likely to be successful if you code the polling directly. Perhaps you
> could use the source for XtAppMainLoop as a guide.
>
> --
> -- Stephe

[-- Attachment #2: Card for Juergen Fischer --]
[-- Type: text/x-vcard, Size: 462 bytes --]

begin:vcard 
n:Fischer;Juergen
tel;pager:+49.(0)168.6957035
tel;cell:+49.(0)170.1630414
tel;fax:+49.(0)7541.282-299
tel;work:+49.(0)7541.282-387
x-mozilla-html:TRUE
url:http://www.avitech.de
org:Aviation Management Technologies GmbH;Software Development
adr:;;Bahnhofplatz 1;Friedrichshafen;Baden-Wuerttemberg;88004;Germany
version:2.1
email;internet:Juergen.Fischer@avitech.de
title:Dr. rer. nat. Dipl.-Math.
x-mozilla-cpt:;-25792
fn:Fischer, Juergen
end:vcard

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

* Re: Using Xt intrinsics with Ada?
  2001-01-31 15:55 Using Xt intrinsics with Ada? Jürgen Grigat
                   ` (3 preceding siblings ...)
  2001-02-01 11:55 ` Tarjei T. Jensen
@ 2001-02-02 16:08 ` Des Walker
  2001-02-02 16:40   ` Juergen Fischer
  4 siblings, 1 reply; 20+ messages in thread
From: Des Walker @ 2001-02-02 16:08 UTC (permalink / raw)


J�rgen Grigat wrote:
> 
> Hi,
> 
> we are developing a program in Ada that has connections to other processes by
> sockets. The calls are done in Ada by using interfaces to C library functions.
> In order to avoid polling we wonder if we can use the event mechanism of X
> Toolkit  Intrinsics. So we created a task which is calling a C-routine that
> itself calls XtAppMainLoop. The main program is an Ada routine.
> From the functional point of view this seems to work. But we recognize a heavy
> CPU load even there is no traffic at the connection.
> 
> Has anyone experience in using X Toolkit events in Ada tasking programs?
> 
> Thanks for any hints.
> 
> J�rgen

Hi J�rgen,

  Just to throw a bit more into the melting pot. We have some
applications using Xt and Ada and don't seem to have had the problem you
describe. It may depend what level of load you mean by a heavy CPU load.

The first issue of our application was built using a Verdix Ada83
compiler and ran on a SPARC5 processor. Multithreading X wasn't
available so we used XtAppAddInput to allow external messages to be
processed in the context of the Main Loop (some messages required an
update to the displayed picture). In the end we settled for separate Ada
tasks to handle the Inet sockets, which queued all their messages on a
single Unix domain socket. It was only the Unix domain socket which was
monitored by Xt. I think the application base load on this processor was
10% of the CPU which was put down to act of maintaining the displayed
picture.

We've subsequently migrated to GNAT Ada and SPARC 50s whilst keeping the
same use of Xt, and the base load has reduced consistently (ie < 1%).

I recall from doing some profiling of the application that the select
function was one of the highest CPU users - In our case, the select
service was the underlying mechanism used by Xt to monitor inputs. I see
others have suggested using select to monitor your sockets, but you may
find that this is what Xt is doing already.

In summary, it's not obvious that the combination of Ada and Xt should
be a problem. I don't know if you have tried profiling your application,
but that may give you some insight as to where the problem lies.

	Des Walker
	Alenia-Marconi Systems



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

* Re: Using Xt intrinsics with Ada?
  2001-01-31 21:40     ` Mario Klebsch
@ 2001-02-02 16:26       ` Juergen Fischer
  0 siblings, 0 replies; 20+ messages in thread
From: Juergen Fischer @ 2001-02-02 16:26 UTC (permalink / raw)
  To: Mario Klebsch

[-- Attachment #1: Type: text/plain, Size: 1091 bytes --]

Hi,

Mario Klebsch wrote:

> Ted Dennison <dennison@telepath.com> writes:
>
> >One caveat that caught my eye in the docs for XtAppAddInput was the
> >following:
>
> >---------------------
> >...you should be careful not to close the end of the socket that is
> >waiting before exiting XtAppMainLoop().  If you do this, you will get an
> >infinite loop, in which the callback is called repeatedly, while the
> >Intrinsics wait for an EOF to be read.
> >-----------------------
>
> >I wouldn't be shocked if this, or a similar problem, was the cause of
> >your troubles.

Thank you for your hint, but this is definitely not the reason for the
trouble. The load problem occurs although no socket is closed.

Juergen

>
>
> It should be sufficient to XtRemoveInput() the descriptor prior to
> closing it.
>
> 73, Mario
> --
> Mario Klebsch                                           mario@klebsch.de
> PGP-Key available at http://www.klebsch.de/public.key
> Fingerprint DSS: EE7C DBCC D9C8 5DC1 D4DB  1483 30CE 9FB2 A047 9CE0
>  Diffie-Hellman: D447 4ED6 8A10 2C65 C5E5  8B98 9464 53FF 9382 F518

[-- Attachment #2: Card for Juergen Fischer --]
[-- Type: text/x-vcard, Size: 462 bytes --]

begin:vcard 
n:Fischer;Juergen
tel;pager:+49.(0)168.6957035
tel;cell:+49.(0)170.1630414
tel;fax:+49.(0)7541.282-299
tel;work:+49.(0)7541.282-387
x-mozilla-html:TRUE
url:http://www.avitech.de
org:Aviation Management Technologies GmbH;Software Development
adr:;;Bahnhofplatz 1;Friedrichshafen;Baden-Wuerttemberg;88004;Germany
version:2.1
email;internet:Juergen.Fischer@avitech.de
title:Dr. rer. nat. Dipl.-Math.
x-mozilla-cpt:;-25792
fn:Fischer, Juergen
end:vcard

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

* Re: Using Xt intrinsics with Ada?
  2001-02-02 16:08 ` Des Walker
@ 2001-02-02 16:40   ` Juergen Fischer
  2001-02-03 14:37     ` Simon Wright
  0 siblings, 1 reply; 20+ messages in thread
From: Juergen Fischer @ 2001-02-02 16:40 UTC (permalink / raw)
  To: Des Walker

[-- Attachment #1: Type: text/plain, Size: 2958 bytes --]

Hi Des,

Des Walker wrote:

> J�rgen Grigat wrote:
> >
> > Hi,
> >
> > we are developing a program in Ada that has connections to other processes by
> > sockets. The calls are done in Ada by using interfaces to C library functions.
> > In order to avoid polling we wonder if we can use the event mechanism of X
> > Toolkit  Intrinsics. So we created a task which is calling a C-routine that
> > itself calls XtAppMainLoop. The main program is an Ada routine.
> > From the functional point of view this seems to work. But we recognize a heavy
> > CPU load even there is no traffic at the connection.
> >
> > Has anyone experience in using X Toolkit events in Ada tasking programs?
> >
> > Thanks for any hints.
> >
> > J�rgen
>
> Hi J�rgen,
>
>   Just to throw a bit more into the melting pot. We have some
> applications using Xt and Ada and don't seem to have had the problem you
> describe. It may depend what level of load you mean by a heavy CPU load.

Although the process is in a wait state the CPU load was about 50%.

>
>
> The first issue of our application was built using a Verdix Ada83
> compiler and ran on a SPARC5 processor. Multithreading X wasn't
> available so we used XtAppAddInput to allow external messages to be
> processed in the context of the Main Loop (some messages required an
> update to the displayed picture). In the end we settled for separate Ada
> tasks to handle the Inet sockets, which queued all their messages on a
> single Unix domain socket. It was only the Unix domain socket which was
> monitored by Xt. I think the application base load on this processor was
> 10% of the CPU which was put down to act of maintaining the displayed
> picture.

We are just migrating from Verdix Ada83 to ObjectAda 95 compiler. In both cases we
use HP-UX OS.  The load problem occurs even when I only monitor one single UNIX
socket by means of XtAppMainLoop although there are no events on this socket.
When I disable all other tasks in the application, there is no CPU load. On the
other hand,
running all application tasks but the task with the XtAppMainLoop does not cause CPU
load,
either. It is only the combination which causes the problem.

Thanks,
Juergen

>
>
> We've subsequently migrated to GNAT Ada and SPARC 50s whilst keeping the
> same use of Xt, and the base load has reduced consistently (ie < 1%).
>
> I recall from doing some profiling of the application that the select
> function was one of the highest CPU users - In our case, the select
> service was the underlying mechanism used by Xt to monitor inputs. I see
> others have suggested using select to monitor your sockets, but you may
> find that this is what Xt is doing already.
>
> In summary, it's not obvious that the combination of Ada and Xt should
> be a problem. I don't know if you have tried profiling your application,
> but that may give you some insight as to where the problem lies.
>
>         Des Walker
>         Alenia-Marconi Systems

[-- Attachment #2: Card for Juergen Fischer --]
[-- Type: text/x-vcard, Size: 462 bytes --]

begin:vcard 
n:Fischer;Juergen
tel;pager:+49.(0)168.6957035
tel;cell:+49.(0)170.1630414
tel;fax:+49.(0)7541.282-299
tel;work:+49.(0)7541.282-387
x-mozilla-html:TRUE
url:http://www.avitech.de
org:Aviation Management Technologies GmbH;Software Development
adr:;;Bahnhofplatz 1;Friedrichshafen;Baden-Wuerttemberg;88004;Germany
version:2.1
email;internet:Juergen.Fischer@avitech.de
title:Dr. rer. nat. Dipl.-Math.
x-mozilla-cpt:;-25792
fn:Fischer, Juergen
end:vcard

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

* Re: Using Xt intrinsics with Ada?
  2001-02-02 15:43       ` Juergen Fischer
@ 2001-02-02 19:30         ` Ted Dennison
  0 siblings, 0 replies; 20+ messages in thread
From: Ted Dennison @ 2001-02-02 19:30 UTC (permalink / raw)


In article <3A7AD594.EAA4A6C6@avitech.de>,
  Juergen Fischer <juergen.fischer@avitech.de> wrote:

> Sorry about that, I am only looking for a solution and it was not my
> intention to polemize against Ada.

I wasn't offended. Anyone who uses Ada in a heavily C domain like GUI
work needs a much thicker skin than that. I was just advocating removing
a gaudy variable.

> > replace your Ada "main" with a C "main", and see what happens. I'll
> > bet you a virtual beer that you get the exact same behavior. :-)
>
> I have reduced the Ada "main" to the start of the XtAppMainLoop. With
> all other tasks switched off  there is no CPU load (same behaviour as
> in a C program). With all other
> tasks switched on but XtAppMainLoop not started the process does not
> CPU, consume either. Only the combination of XtAppMainLoop and the
> other application tasks leads to CPU load although the application,
> after initialization, is in a wait state.

Ahhh, you've already done that then. It looks like I'm going to end up
owing you that virtual beer. :-(


> I compiled the Ada Sources with ObjectAda 7.1.2. The OS is HP_UX
> 10.20.

I'm not familiar with that compiler on that platform. It might be worth
finding out what OS mechanisms it uses to accomplish tasking (since you
said elsewhere it isn't using OS threads). There ought to be some clues
to that in your compiler docs.

--
T.E.D.

http://www.telepath.com/~dennison/Ted/TED.html


Sent via Deja.com
http://www.deja.com/



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

* Re: Using Xt intrinsics with Ada?
  2001-02-02 16:40   ` Juergen Fischer
@ 2001-02-03 14:37     ` Simon Wright
  0 siblings, 0 replies; 20+ messages in thread
From: Simon Wright @ 2001-02-03 14:37 UTC (permalink / raw)


Juergen Fischer <juergen.fischer@avitech.de> writes:

> We are just migrating from Verdix Ada83 to ObjectAda 95 compiler. In
> both cases we use HP-UX OS.  The load problem occurs even when I
> only monitor one single UNIX socket by means of XtAppMainLoop
> although there are no events on this socket.  When I disable all
> other tasks in the application, there is no CPU load. On the other
> hand, running all application tasks but the task with the
> XtAppMainLoop does not cause CPU load, either. It is only the
> combination which causes the problem.

It really does sound as though there is a nasty interaction between OA
tasking and HP-UX's select() (or poll(), depends what they have in the
innards of XtAppMainLoop()). Tasking is quite likely to use signals,
perhaps they're interfering ..

It won't help you much to know that we've not seen this problem with
Verdix/Solaris, DEC Ada/OSF1.3, GNAT/Solaris, GNAT/Linux :-)

Do Aonix have a view?

Is there a GNAT port for your machine (would be useful just as a
comparison point).

-- 
Simon Wright                       Work Email: simon.j.wright@amsjv.com
Alenia Marconi Systems                        Voice: +44(0)23-9270-1778
Integrated Systems Division                     FAX: +44(0)23-9270-1800



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

* Re: Using Xt intrinsics with Ada?
  2001-02-02 15:48       ` Juergen Fischer
@ 2001-02-05 15:06         ` Stephen Leake
  0 siblings, 0 replies; 20+ messages in thread
From: Stephen Leake @ 2001-02-05 15:06 UTC (permalink / raw)


Juergen Fischer <juergen.fischer@avitech.de> writes:

> > You can either get threads and sockets libraries that provide this
> > functionality, or convert your program to a multi-process one,
> > possibly using Ada partitions. Which OS and compiler are you using?
> 
> HP_UX 10.20 and Aonix ObjectAda 7.1.2

Although it won't help you immediately, please request that Aonix
provide a task-level blocking sockets library on this OS. The squeaky
wheel (with a support contract :) gets the grease!

-- 
-- Stephe



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

end of thread, other threads:[~2001-02-05 15:06 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-31 15:55 Using Xt intrinsics with Ada? Jürgen Grigat
2001-01-31 18:14 ` Stephen Leake
2001-02-02  9:58   ` Juergen Fischer
2001-02-02 12:00     ` Jeff Creem
2001-02-02 15:02     ` Ted Dennison
2001-02-02 15:43       ` Juergen Fischer
2001-02-02 19:30         ` Ted Dennison
2001-02-02 15:06     ` Stephen Leake
2001-02-02 15:48       ` Juergen Fischer
2001-02-05 15:06         ` Stephen Leake
2001-02-02 15:21     ` Robert Dewar
2001-01-31 19:19 ` Ted Dennison
2001-01-31 21:07   ` Ted Dennison
2001-01-31 21:40     ` Mario Klebsch
2001-02-02 16:26       ` Juergen Fischer
2001-01-31 19:42 ` Kevin Kronmiller
2001-02-01 11:55 ` Tarjei T. Jensen
2001-02-02 16:08 ` Des Walker
2001-02-02 16:40   ` Juergen Fischer
2001-02-03 14:37     ` Simon Wright

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