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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a6e8237dc15142a0,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews2.google.com!not-for-mail From: unclejimmymayte@hotmail.com (Daniel Wild) Newsgroups: comp.lang.ada Subject: Resolving a deadlock Date: 24 Aug 2004 17:28:32 -0700 Organization: http://groups.google.com Message-ID: NNTP-Posting-Host: 202.139.137.236 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1093393712 11617 127.0.0.1 (25 Aug 2004 00:28:32 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 25 Aug 2004 00:28:32 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:2977 Date: 2004-08-24T17:28:32-07:00 List-Id: Hi, I got a deadlock problem that I'm trying to resolve but I can't find a way to get it to work. The situation is: Task A is calling an entry in Task B to tell it to shut down, but Task B is calling an entry in Task A to pass it some data. The obvious solution is to add a select ... or delay ... end select construct around the call from Task B to Task A so that it will time out and be able to accept the call from Task A to shut down. But, Task B looks something like this (this might not compile, but it's the same idea): generic with procedure Task_Entry; package B_Package is task type B_Task_Type is entry Start; entry Stop; end B_Task_Type; task body B_Task_Type is begin select accept Start; or terminate; end select; loop select accept Stop; exit; or delay 0.1; -- Do some processing -- ... -- Call task entry Task_Entry; end select; end loop; end B_Task_Type; end B_Package; Adding a select ... or delay ... end select around the call to Task_Entry in the Task B main loop causes a compiler error because it needs a task entry. The compiler thinks that it is just a procedure because that's the way it is passed in when the package is instantiated. So, to fix that you would pass in a procedure as Task_Entry, and in that procedure do the timed entry call, right? Well, that works. The problem with that is that this is only one implementation of this package, and the other one relies on Task_Entry (the generic parameter) being a task entry. Using a procedure for this won't work on the other implementation. Has anyone got any ideas on another way to make this work? I've had a look for pragmas to tell the compiler that it really is a Task_Entry, but things like pragma Convention don't ley you specify 'Entry' as the calling convention. I'm using ObjectAda 7.2.2 for this (the other implementation uses Apex 2.0.8C). Daniel.