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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "G.B." Newsgroups: comp.lang.ada Subject: Re: How to simulate semaphores with Ada's tasks? Date: Thu, 25 Aug 2016 09:55:12 +0200 Organization: A noiseless patient Spider Message-ID: References: <35ae841e-5947-44e9-a8d4-479cf40c4277@googlegroups.com> Reply-To: nonlegitur@futureapps.de Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 25 Aug 2016 07:55:09 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="1499b2d4240d82ead8f34044ca0ceb38"; logging-data="1321"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/7H/5YN8uK/UbMcFHVAAlNioyU2qI4IFY=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 In-Reply-To: <35ae841e-5947-44e9-a8d4-479cf40c4277@googlegroups.com> Cancel-Lock: sha1:deq+6PVqcX9TLVxskunwb+xX9+I= Xref: news.eternal-september.org comp.lang.ada:31562 Date: 2016-08-25T09:55:12+02:00 List-Id: On 25.08.16 02:41, Andrew Shvets wrote: > From what I've read, tasks do not have semaphores that can permit it to lock a piece of memory and prevent it from being accessed, is this correct? > > If so, then the best possible way to simulate this is to have tasks send messages to one another and synchronize when something is locked/unlocked. Is there a better approach? > The thing is called Suspension_Object in Ada, see Ada.Synchronous_Task_Control (RM D.10). But, as others have said, it might be a good idea to consider the use case and arrive at a protected resource. -- "HOTDOGS ARE NOT BOOKMARKS" Springfield Elementary teaching staff