From: dennison@telepath.com
Subject: Re: Tasks and C/C++ code.
Date: 1998/11/10
Date: 1998-11-10T00:00:00+00:00 [thread overview]
Message-ID: <729ndu$jfo$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 364702E5.F6987321@hiwaay.net
In article <364702E5.F6987321@hiwaay.net>,
bdorough@phaseiv.com wrote:
> I am working on a project where we need to call the same C function
> from multiple tasks. I am wondering how to do this safely. Can I make
> a generic with my C pragma defined there are do I need to define the
> prama in the task type so each task will have its own copy of the C
> function.
If the C function truly isn't safe to call from multiple threads (iaw: relies
on global data, "static" local declarations, or calls other non-thread safe
routines) then you have to ensure that calls to it happen from only one
thread. The safest way to do it is to make *one* server task responsible for
calling the routine and returning its results. Client tasks rendezvous with
the server task to request a call to the unsafe C routine. This is the method
used in at least one set of X/Motif Ada bindings.
A generic won't do any good, because you end up with multiple bindings to the
*same* C routine, not multiple copies of the C routine itself. A task type
won't work for roughly the same reason, unless you only allow *one* object of
that type. Even then you could have problems with object caching and
thread-local data.
--
T.E.D.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
next prev parent reply other threads:[~1998-11-10 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 [this message]
1998-11-11 0:00 ` dbotton
1998-11-11 0:00 ` dennison
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 ` Tom Moran
1998-11-27 0:00 ` Jerry van Dijk
1998-11-28 0:00 ` Tom Moran
1998-11-27 0:00 ` Mats Weber
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