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,474c04ac0211c5fa X-Google-Attributes: gid103376,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: Explicit Posix/Notify() vs Guards Date: 1997/09/08 Message-ID: #1/1 X-Deja-AN: 270723477 Sender: news@inmet.camb.inmet.com (USENET news) References: <5utrqp$3ip$1@goanna.cs.rmit.edu.au> X-Nntp-Posting-Host: houdini.camb.inmet.com Organization: Intermetrics, Inc. Newsgroups: comp.lang.ada Date: 1997-09-08T00:00:00+00:00 List-Id: Dale Stanbrough (dale@goanna.cs.rmit.EDU.AU) wrote: : The Posix/Threads model (and Java) provide explicit notification schemes : for informing sleeping threads when to reevaluate any barrier conditions. : Ada provide guards on entries, and relies on the run time system to : recognise when the condition associated with a guard _may_ have changed. : Clearly the Ada model may end up being overly conservative, : recalculating the barrier condition more often than is needed. : In some ways it may be less flexible in that other tasks may be : unable to cause reevaluation of the guards, in the same way : that an explicit notify would. : Is this a reasonable analysis, and what benefits are gained from : Ada's model? A major advantage of the Ada model is that as more operations are added to a protected type, the compiler keeps track of what are the "interesting" state changes. With an explicit notify, every operation must decide when to notify which condition variables. When the number of operations increase, you can begin to encounter a combinatorial explosion of cases. The most important advantage of the Ada model is that it is state oriented, meaning that the programmer identifies the interesting states via the barriers, and the compiler+run-time-system worries about making sure these states are satisfied at the time the corresponding entry body executes. With the explicit notification approach, there is no guarantee that the desired state is still present when a task wakes up, so the required paradigm is that all "wait"s are inside while-loops, rechecking the desired state on every wakeup. This can result in unnecessary wakeups, or even worse, missed wakeups. Furthermore, with the explicit notification model, a context switch must be performed in addition to a lock ownership change to accomplish every operation. With Ada, the "convenient" thread performs the entry body whose barrier becomes true, without any necessary lock ownership transfer, and without extra context switches. It is relatively easy to show that with a simple producer/buffer/consumer example, the Ada approach can result in one third as many context switches, and half as many locks and unlocks as the explicit notify approach. : Dale -- -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Burlington, MA USA