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,fc232b1f37897ed0,start X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: D.10 Date: 1999/04/12 Message-ID: #1/1 X-Deja-AN: 465402098 NNTP-Posting-Date: Mon, 12 Apr 1999 02:13:10 PDT Newsgroups: comp.lang.ada Date: 1999-04-12T00:00:00+00:00 List-Id: Paragraph D.10 (7) states that "The operations Set_True and Set_False are atomic with respect to each other and with respect to Suspend_Until_True..." Q: Is Suspend_Until_True atomic with respect to Suspend_Until_True? In 12.3.1 of Burns and Wellings, they state that a semaphore can be used to program mutual exclusion between two tasks, like this: Sema : Suspension_Object; task T; T1, T2 : T; task body T is begin Set_True (Sema); ... Suspend_Until_True (Sema); Set_True (Sema); ... end T; The suspension object is true. Now suppose the two tasks try to call Suspend_Until_True at the same time. Is this an atomic operation? The assumption by Burns and Wellings seems to be that, one of the tasks will get the suspension object first, find that it's already true, wake up (or just stay awake), and set the flag back to false as a side-effect of the Suspend_Until_True call. The other task, who got in a little later, finds the suspension object is false, and goes to sleep, until the first task finishes its critical region, and sets the suspension object back to true. Is this a legitimate scenario? The RM states that PE gets raised if one task calls Suspend_Until_True and another task is already waiting on the same object. But what does "already waiting on the suspension object" mean? Does it mean that the task has started calling Suspend_Until_True, and isn't finished yet when the other task calls Suspend_Until_True? Does the statement "waiting on the suspension object" include the time when one object calls Suspend_Until_True, and the suspension object is already true? Or does it only refer to the time when a task calls Suspend_Until_True, and goes to sleep because the suspension object is false? Can calls to Suspend_Until_True interleave?