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: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Protected Objects and Interrupt Handlers Date: Wed, 24 Feb 2016 18:29:23 +0000 Organization: A noiseless patient Spider Message-ID: References: <7663896a-a15e-47fd-8c7e-54a1c20d8d0f@googlegroups.com> <85b5c378-dbaf-459b-afcd-dc5ed7692ee9@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="03d977edd803a9f1bf346d48fa393156"; logging-data="11980"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+G8A/hQJAelp+F2xLS1qoqSnVRhmVIn2s=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) Cancel-Lock: sha1:sjMLdP7EmUAor/AT1X0aun4G3p0= sha1:xvHnPjuO7JF6nAKZWDtkoDFVmOI= Xref: news.eternal-september.org comp.lang.ada:29599 Date: 2016-02-24T18:29:23+00:00 List-Id: Jere writes: > I would expect a protected entry or procedure to employ a different > type of synchronization construct (maybe similar to a > mutex/semiphore/etc.??) to keep multiple tasks from changing the data > in the protected object at the same time than is needed for > interrupts. For interrupts I would expect something more like > disabling interrupts to be appropriate. Does a protected > object/procedure behave differently for interrupts than it does for > tasks under the hood and Ada is able to handle all those details based > on the existence of the pragma used? GNAT (don't forget there are other Ada compilers!) handles differences between tasks & interrupts calling protected procedures very similarly; the difference is, I believe, in the way locks are handled. I don't know too much about the way AdaCore's bare board implementation does this; the way I dealt with this at [1] was to implement System.Tasking.Protected_Objects.Lock and .Lock_Read_Only as if in an ISR then null; elsif this PO's ceiling priority is an interrupt priority then -- we are in a task, but this PO deals with interrupts, so we -- mustn't be interrupted disable interrupts; else -- we are in a task and this PO doesn't deal with interrupts take the PO's mutex; raise the priority to the PO's ceiling end if; [1] https://sourceforge.net/projects/cortex-gnat-rts/