comp.lang.ada
 help / color / mirror / Atom feed
From: dennison@telepath.com
Subject: Re: Imported Monolitic Monitor
Date: 1999/03/05
Date: 1999-03-05T00:00:00+00:00	[thread overview]
Message-ID: <7bpgb7$bmm$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 36E014CD.55717933@unex.es

In article <36E014CD.55717933@unex.es>,
  "Juan Carlos =?iso-8859-1?Q?D=EDaz=20Mart=EDn?=" <juancarl@unex.es> wrote:
> Let's be the C procedures in a module that share global data
>
>  a
>  b
>  c
>
> and I make a C library with them. This library will be used by a
> multitasked Ada95 application by the pragma Import
>
> Tasks T, Q and R may invoke a, b or c in a concurrent, uncontrolled way.
> Isn't it? I'm interested in a, b and c to be executed in mutual
> exclusion to preserve global data integrity. The question is: How do I
> do it in Ada95?
> I've thought in a protected object, such as:
>
> protected Monitor is
>   procedure a;
>   procedure b;
>   procedure c;
> end Monitor;

> Does this way guarantee mutual exclusion of a, b and c??? Any ideas??

Yup, as long as everyone goes through the Monitor protected object to call a,
b, and c. You could make this more transparent to users by just putting
procedure calls in the spec of a "C" package. Put Monitor in the body, and
have the body of the procedures call the protected procedures in Monitor.
That way it looks just like normal procedure calls to everyone else.

Of course if you are going to do it that way, it would be just as easy to
create a simple lock using a protected object, and have the bodies of all the
procedures acquire the lock, then call the imported procedure, then release
the lock.

T.E.D.

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




  reply	other threads:[~1999-03-05  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-03-05  0:00 Imported Monolitic Monitor Juan Carlos Díaz Martín
1999-03-05  0:00 ` dennison [this message]
1999-03-07  0:00   ` Nick Roberts
1999-03-08  0:00     ` robert_dewar
replies disabled

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