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.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Uneasy thoughts about priorities, priority inversion and protected objects Date: Fri, 27 Feb 2015 13:59:24 +0100 Organization: A noiseless patient Spider Message-ID: References: <0925a2da-6cd2-4c06-bd20-1ffb3d14156b@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 27 Feb 2015 12:58:43 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="23dab0694e4174fdc880833ec67fa650"; logging-data="9902"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/4WIw9Qt258skgUBRtV9OZ" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 In-Reply-To: <0925a2da-6cd2-4c06-bd20-1ffb3d14156b@googlegroups.com> Cancel-Lock: sha1:1mQdKMpydv9XgbOc8uTPBxySrDA= Xref: number.nntp.giganews.com comp.lang.ada:192363 Date: 2015-02-27T13:59:24+01:00 List-Id: Le 27/02/2015 12:59, Jean François Martinez a écrit : > Both Burns in his "Concurrent and Real Time Programming in Ada" and > JP Rosen in his wikibook (in French) about software engineering > "implement" (note the scare quotes) protected objects by giving a > priority to the protected object that is inherited by a task when it > runs in it. [...] This is required only if you specify pragma Locking_Policy (Ceiling_Locking) > Problem is: there are still priority inversions. Let's consider the > following scenario. Task High is sleeping, Task Medium is waiting > for I/O, Task Low is in protected Object. Now I/O completes so Task > Medium should get the processor but it doesn't because Low is in > protected object with High's priority or more. But nobody is waiting > for the protected object so there is no hurry in getting Low out of > it and no reason to delay Medium jsut because Low is in Protected > Object. Scheduling is based on the active priority, so when Low inherits a high priority, it won't let Medium run (on a mono-processor). > It seems to me a task on a protected object should have its priority > raised only when a task with a higher priority queues behind it. This is called priority inheritance. It has the benefit of saving useless priority changes, at the cost of a more complicated priority change when required (a task has to change the priority of another task while it is in the PO). > Since I don't think for a second none of the smart people who > designed Ada and none of the smart people who have read either the > ARM, Burns'book or Rosen's wikibook haven't ever had a so obvious > idea why is that we still are in the model I described on the first > paragraph? Because it is simpler to implement? Because it is no big > deal? (You are supposed to leave the protected object _fast_). Or > is it because I missed someting? When it comes to scheduling, for any algorithm, you can find an example where it makes perfect sense, and an example where it would be catastrophic. The "best" algorithm depends highly on your requirements and your application profile. -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 http://www.adalog.fr