From: Mats Weber <Mats.Weber@elca-matrix.ch>
Subject: Re: Blocking protected ops (was: Tasks and C/C++ code)
Date: 1998/11/27
Date: 1998-11-27T00:00:00+00:00 [thread overview]
Message-ID: <365EEAFA.2D636FD2@elca-matrix.ch> (raw)
In-Reply-To: 73mo00$24ik$1@news.gate.net
David Botton wrote:
>
> After all the discussion on this issue, I am not sure how to implement a
> call to gethosbyname any more.
>
> Would some one post a correct implementation of this and if one can wrap
> gethostbyname in to a protected type so it can be called by multiple task
> instances even if it (gethostbyname) is not thread safe.
An example of how to do it can be found in:
<ftp://cs.nyu.edu//pub/gnat/glade/glade-1.03p.tar.gz>
or copy this code (compiled, not tested):
protected Semaphore is
entry Seize;
entry Release;
private
Busy : Boolean := False;
end Semaphore;
protected body Semaphore is
entry Seize when not Busy is
begin
Busy := True;
end;
entry Release when Busy is
begin
Busy := False;
end;
end Semaphore;
function Gethostbyname (Name : in System.Address)
return System.Address; -- pointer to hostent
pragma Import(C, Gethostbyname);
function Protected_Gethostbyname (Name : in System.Address)
return System.Address is
Result : System.Address;
begin
Semaphore.Seize;
Result := Gethostbyname(Name);
Semaphore.Release;
return Result;
exception
when others =>
Semaphore.Release;
raise;
end Protected_Gethostbyname;
it would be nice to put the call to gethostbyname inside a protected
procedure (so that you need only one protected call instead of two), but
this does not seem to be allowed as gethostbyname could be potentially blocking.
next prev parent reply other threads:[~1998-11-27 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
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 [this message]
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