comp.lang.ada
 help / color / mirror / Atom feed
From: smize@news.imagin.net (Samuel Mize)
Subject: Can a protected action tie up the calling task?
Date: 1997/10/27
Date: 1997-10-27T00:00:00+00:00	[thread overview]
Message-ID: <6331fk$nm0$1@prime.imagin.net> (raw)


Greetings,

I need to verify a point on how protected actions work.  Please email
me, as my news feed provides *very* variable delays.

My understanding is that, after an entry or procedure completes, the
queues for that object are serviced as far as possible before the
protected action completes.  This is done by any convenient thread of
control (ARM 9.5.3(22)).  This permission ALLOWS but does not REQUIRE
that the task calling the entry or procedure be released before the
protected action completes.

Thus, in the following example, if another task has already called
Complete before task T1 calls Prepare:

- T1's thread of control can execute Complete;

- this COULD keep T1 suspended until Complete terminates.

Example:

     protected Monitor is
      entry Prepare (D: in Data);
      entry Complete;
    private
      Ready_To_Complete: boolean := false;
    end Monitor;

    protected body Monitor is
      entry Prepare (D: in Data)
      when not Ready_To_Complete is
        ...
      entry Complete
      when Ready_To_Complete is
        ...
    end Monitor;

So to ENSURE that T1 can continue processing IMMEDIATELY on completion
of Prepare, we must ensure that Complete is not called before Prepare.
A third entry is probably the simplest way to do this (task T2 calls
Wait_For_Preparation, then Complete).

    protected Monitor is
      entry Prepare (D: in Data);
      entry Wait_For_Preparation;
      procedure Complete;
    private
      Ready_To_Complete: boolean := false;
    end Monitor;

    protected body Monitor is
      entry Prepare (D: in Data)
      when not Ready_To_Complete is
        ...
      entry Wait_For_Preparation
      when Ready_To_Complete is
        ...
      procedure Complete is
        ...
    end Monitor;

Is this correct?  Have I missed something?

Thanks,
Sam Mize

-- 
Samuel Mize -- smize@imagin.net -- Team Ada
(personal net account)




             reply	other threads:[~1997-10-27  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-27  0:00 Samuel Mize [this message]
1997-10-28  0:00 ` Can a protected action tie up the calling task? Tucker Taft
replies disabled

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