From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6ff6ac051491e437 X-Google-Attributes: gid103376,public From: bsanden@site.gmu.edu (Bo I. Sanden) Subject: Re: Question about the need for requeue as described in Rationale Date: 1996/07/05 Message-ID: <4rjimv$glk@portal.gmu.edu>#1/1 X-Deja-AN: 163875504 references: <31c8fdd4.5a455349@zesi.ruhr.de> <31DAD51F.40F1@csehp3.mdc.com> content-type: text/plain; charset=US-ASCII organization: George Mason University, Fairfax, Virginia, USA mime-version: 1.0 newsgroups: comp.lang.ada Date: 1996-07-05T00:00:00+00:00 List-Id: 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 ---------------------------------------------------------------------