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!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Advice, tasking and hardware Date: Thu, 26 May 2016 12:35:04 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <25c43463-47ca-4021-82ee-299e6a075faa@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Date: Thu, 26 May 2016 19:31:27 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="48b46be33beed75863f69afa437f956b"; logging-data="32043"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19mBPLYpz5mD96c1lm6lAGCsszvNN7f0BQ=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 In-Reply-To: Cancel-Lock: sha1:vUecd0amMJqCYKn50LN2/TgjLHs= X-Enigmail-Draft-Status: N1110 Xref: news.eternal-september.org comp.lang.ada:30487 Date: 2016-05-26T12:35:04-07:00 List-Id: On 05/26/2016 12:26 AM, Dmitry A. Kazakov wrote: > > If you want interlocking for doing blocking calls use a mutex etc. A mutex > implementation based on protected objects is two actions: Seize and Release. To the OP: This is terrible advice. One should only use a low-level mechanism such as a semaphore when one can't achieve what one needs with the high-level mechanisms provided by the language: tasks and protected objects. Since there's no way for the compiler to know that the subprogram is potentially blocking, there's no reason not to put the call in a PO and make use of the high-level mutual exclusion it provides. Even if the system has problems with the call being in a protected operation, it's better to put a request for the call on a protected queue and have a task that gets the requests from the queue and makes the calls than to use a semaphore. -- Jeff Carter "This trial is a travesty. It's a travesty of a mockery of a sham of a mockery of a travesty of two mockeries of a sham. ... Do you realize there's not a single homosexual on that jury?" Bananas 27