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: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: multiple delay alternative Date: Tue, 6 Mar 2018 14:06:03 -0600 Organization: JSA Research & Innovation Message-ID: References: <90838aa0-bd51-4913-b0cf-1ded5024c151@googlegroups.com> <212bf1a1-1bcc-4474-b1f6-b98c1461ff07@googlegroups.com> Injection-Date: Tue, 6 Mar 2018 20:06:03 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="28254"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:50855 Date: 2018-03-06T14:06:03-06:00 List-Id: "Mehdi Saada" <00120260a@gmail.com> wrote in message news:212bf1a1-1bcc-4474-b1f6-b98c1461ff07@googlegroups.com... >>> Functions are like procedures except that logically allowed to run >>> parallel to each other. > Ok, but aren't calls on protected procedures blocked when other tasks is > executing them ? Not necessarily. On a monoprocessor, you are right in that waiting is essentially the same as blocking (the current task has to be suspended so that the protected operation can run and complete). But on a multiprocessor, this is different as the protected operation is actively running on a different thread. So the task that is waiting is doing literally that, waiting for the lock to change. This does not necessarily cause the task to be suspended, it's not an abort point, and so on. It's often just a loop: while not Protected.Lock loop null; -- Possibly waste some time here. end loop; In a properly designed protected object, the time of operations will be short and this will not waste significant processing time. (And it doesn't happen that much in practice, tasks usually are doing other things than calling POs.) So just wasting time in this way is the often the most efficient thing to do, as blocking (which requires a full context switch) is rather expensive. Randy.