comp.lang.ada
 help / color / mirror / Atom feed
From: bsanden@site.gmu.edu (Bo I. Sanden)
Subject: Re: Question about the need for requeue as described in Rationale
Date: 1996/07/05
Date: 1996-07-05T00:00:00+00:00	[thread overview]
Message-ID: <4rjimv$glk@portal.gmu.edu> (raw)
In-Reply-To: 31DAD51F.40F1@csehp3.mdc.com


James A. Squire (m193884@CSEHP3.MDC.COM) wrote:
: I am trying to understand what problem Requeue is trying to solve and
: the above does not help me.  I can see from the example given how it
: would be difficult to do the same thing in Ada83, but as I was trying to
: describe the Ada83 problem that raised the need for this, I found I
: couldn't come up with any good way of describing the problem.

In my understanding, requeue is "needed" in Ada 95 primarily as part of
the effort to replace by protected units what was sometimes called 
guardian tasks in Ada 83. Guardian tasks execute only while being
called by other task, and made a typical Ada 83 program contain more 
tasks than the inherent concurrency of the problem would suggest. 
(Guardian tasks where there to restrict concurrency by enforcing 
synchronization of other tasks.)

The following example appears in full in the March 96 issue of the Ada
User Journal: There are a number of tasks each responsible for the 
heating of a home. The monitor shown below enforces rationing. For reasons
known only to the originators of this example, only 4 out of 5 homes
(say) can be heated at the same time. But a home can be without 
heating forcibly for no more than 10 minutes. After having waited for
heat that long, a home task calls the Insist entry. A call to Insist 
causes a switch to be set that in turn will cause one of the other 
homes to turn off its heat. After setting the switch, the call to 
Insist is requeue until another home has shut down its heating in 
an orderly fashion and called Release.

In Ada 83, Monitor is a guardian task and the wait is implemented by
a statement accept Release nested within the body of accept Insist.
This is not allowed in a protected unit, and instead requeue is used.

protected body Monitor is
    .......
   
    entry Wait (H: Hnum) when Active < Home_Num - 1 is
    begin
        Active := Active + 1;
    end Wait;

    entry Insist (H: Hnum) when Wait'count = 0 is
    begin
        if Active < Home_Num - 1 then
            ......
        else
            Auto_Status(...) := Off;      -- Set switch
            requeue Wait;                 -- Wait for shut-down
        end if;
    end Insist;

    procedure Release (I: Hnum) is
    begin
        Active := Active - 1;
    end Release;
end Monitor;

---------------------------------------------------------------------
Dr. Bo Sanden					Author of:
Mail Stop 4A4				Software Systems Construction
George Mason University			    with examples in Ada
Fairfax, VA 22030-4444, USA		     Prentice-Hall 1994

        Tutorials on concurrent/real-time software design
                      at WAdaS and TRI-Ada
             http://www.isse.gmu.edu/faculty/bsanden
---------------------------------------------------------------------




  reply	other threads:[~1996-07-05  0:00 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-06-20  0:00 GNAT Codesize Haug Buerger
1996-06-20  0:00 ` James E. Hopper
1996-06-21  0:00 ` Ralph Paul
1996-06-21  0:00 ` Robert Dewar
1996-06-24  0:00   ` John McCabe
1996-06-24  0:00     ` John Howard
1996-06-25  0:00       ` Robert Dewar
1996-06-25  0:00       ` David J. Fiander
1996-06-26  0:00     ` Robert Dewar
1996-06-28  0:00       ` John McCabe
1996-06-28  0:00         ` Fergus Henderson
1996-06-29  0:00           ` John McCabe
1996-07-01  0:00             ` Robert Dewar
1996-07-05  0:00               ` John McCabe
1996-07-05  0:00             ` JP Thornley
1996-06-30  0:00         ` Robert Dewar
1996-07-02  0:00           ` John McCabe
1996-07-03  0:00             ` Robert Dewar
1996-06-28  0:00       ` Fergus Henderson
1996-07-01  0:00         ` Michael Feldman
1996-07-03  0:00           ` John McCabe
1996-07-02  0:00         ` John McCabe
1996-07-03  0:00           ` Robert Dewar
1996-07-06  0:00             ` John McCabe
1996-07-06  0:00               ` Robert Dewar
1996-07-06  0:00               ` Michael Feldman
1996-07-08  0:00             ` Gavin Smyth
1996-07-03  0:00   ` Question about the need for requeue as described in Rationale James A. Squire
1996-07-05  0:00     ` Bo I. Sanden [this message]
1996-07-05  0:00       ` progers
1996-07-06  0:00     ` Robert A Duff
1996-07-04  0:00   ` Samuel Tardieu
1996-07-04  0:00     ` Robert Dewar
1996-07-08  0:00   ` James A. Squire
1996-07-08  0:00     ` Robert A Duff
1996-07-09  0:00     ` Bo I. Sanden
1996-07-08  0:00   ` James A. Squire
1996-07-08  0:00   ` James A. Squire
1996-07-09  0:00     ` progers
1996-07-10  0:00     ` Robert A Duff
1996-07-10  0:00       ` progers
1996-07-09  0:00   ` Jon S Anthony
1996-06-21  0:00 ` GNAT Codesize Doug Smith
1996-07-08  0:00 ` Question about the need for requeue as described in Rationale James A. Squire
replies disabled

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