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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!g1g2000vbr.googlegroups.com!not-for-mail From: =?UTF-8?Q?Tomek_Wa=C5=82kuski?= Newsgroups: comp.lang.ada Subject: Re: How to determine if task is busy or not? Date: Sat, 8 Aug 2009 09:00:13 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <063cfc19-a8fa-41af-b948-d4f8540cb2ab@o36g2000vbl.googlegroups.com> <4aef99b6-6ac6-4e0b-91d8-2a5320ea6e9c@l34g2000vba.googlegroups.com> NNTP-Posting-Host: 79.185.181.228 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1249747213 5292 127.0.0.1 (8 Aug 2009 16:00:13 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 8 Aug 2009 16:00:13 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: g1g2000vbr.googlegroups.com; posting-host=79.185.181.228; posting-account=Ar5oKAoAAAD4cyp5eTv5CtR88dGtUxxC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.9.1.2) Gecko/20090803 Fedora/3.5.2-2.fc11 Firefox/3.5.2,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:7662 Date: 2009-08-08T09:00:13-07:00 List-Id: On 8 Sie, 16:59, Maciej Sobczak wrote: > Depends. If it is the asking entity that is also providing the job, > then the problem above cannot happen. In other words, if the "manager" > asks the task whether it is busy or idle and the answer is "idle", > then that answer it true until the same manager provides new work > unit, because there is no other way for the task to switch from "idle" > to "busy". Which means that the manager can always safely handle a new > work unit to the "idle" task, no race is possible. > Only manager is providing work to the tasks. So, as you said, no race is possible. > To Tomek - the simplest way to deploy your original idea is to use a > flag (Busy/Idle - an enumeration type is perfect here), which is > shared and used by both the worker task and its manager. Protected > object is a proper solution here and you might even use the same > protected object for managing both the flag and the work unit itself. > That was my first thought :)