comp.lang.ada
 help / color / mirror / Atom feed
From: dennison@telepath.com
Subject: Re: Tasks and C/C++ code.
Date: 1998/11/11
Date: 1998-11-11T00:00:00+00:00	[thread overview]
Message-ID: <72coif$653$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 72b35b$pll$1@nnrp1.dejanews.com

In article <72b35b$pll$1@nnrp1.dejanews.com>,
  dbotton@hotmail.com wrote:
> I think it would be practical to create a protected type that wrapped your C
> function to insure that it is not be run concurrently (if it isn't safe). If
> it's safe then just call it as you would any other Ada Procedure/Function.

That will only work under both of the following conditions:

 o There is only *one* object of that protected type in use.

If there are multiple objects of the protected type declared, then there's
nothing stopping two tasks from using different protected objects to call the
same routine simultaniously.

 o The C routine in question does not rely on task-local data for proper
operation or for parameter data.

In Ada we are used to data being either local in *scope*, or visible to all
tasks. But this is not nessecarily true when we leave Ada's happy confines.

eg: The Nighthawk Ada compiler splits tasks into separate Unix processes. All
Ada memory allocations are performed from shared memory sections. However,
their C compiler and OS library routines allocate memory from process space.
That means any data that was dynamicly allocated by a different task within a
C routine or OS library routine is unreadable from any but the calling task.
Thus calling X or Motif routines directly from different tasks will blow up,
regarless of how the calls are synchronized.

Many of the newer threaded OS'es have the concept of "thread-local" data. That
could cause the same problem.

--
T.E.D.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




  reply	other threads:[~1998-11-11  0:00 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-11-09  0:00 Tasks and C/C++ code Barry L. Dorough
1998-11-09  0:00 ` Mats Weber
1998-11-10  0:00 ` dennison
1998-11-11  0:00   ` dbotton
1998-11-11  0:00     ` dennison [this message]
1998-11-11  0:00     ` Barry L. Dorough
1998-11-11  0:00       ` dennison
1998-11-12  0:00       ` Jerry van Dijk
1998-11-13  0:00       ` Mats Weber
1998-11-18  0:00     ` Samuel Tardieu
1998-11-19  0:00       ` Mats Weber
1998-11-20  0:00         ` Samuel Tardieu
1998-11-23  0:00           ` Mats Weber
1998-11-23  0:00             ` Tom Moran
1998-11-24  0:00               ` Blocking protected ops (was: Tasks and C/C++ code) Mats Weber
1998-11-24  0:00                 ` Robert I. Eachus
1998-11-25  0:00                   ` Mats Weber
1998-11-25  0:00                     ` Robert I. Eachus
1998-11-26  0:00                       ` Simon Wright
1998-11-27  0:00                         ` David Botton
1998-11-27  0:00                           ` Mats Weber
1998-11-27  0:00                           ` Tom Moran
1998-11-27  0:00                             ` Jerry van Dijk
1998-11-28  0:00                               ` Tom Moran
1998-11-29  0:00                         ` Tucker Taft
1998-11-30  0:00                           ` Simon Wright
1998-11-25  0:00                     ` Jean-Pierre Rosen
1998-11-27  0:00                       ` Mats Weber
replies disabled

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