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 X-Google-Thread: 103376,92a027c293f03acb X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Workqueues in Ada Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <4rvzewqs9ba3$.pluy1xzoi5lr$.dlg@40tude.net> Date: Sat, 28 Jul 2007 22:45:38 +0200 Message-ID: <16fd0klj7ul1d$.oi8lp7eybgxo$.dlg@40tude.net> NNTP-Posting-Date: 28 Jul 2007 22:45:26 CEST NNTP-Posting-Host: ba1f7f74.newsspool1.arcor-online.net X-Trace: DXC=O_VfOXZJK\WFm0Y?OE@2^Xic==]BZ:af^4Fo<]lROoRQFl8W>\BH3YR@d>KKY5RmSVDNcfSJ;bb[UIRnRBaCd On Sat, 28 Jul 2007 17:52:29 +0000 (UTC), Wiktor Moskwa wrote: >> Make it a protected object. A worker task calls to an entry of, requesting >> an item of work. The entry removes the first item from the list and returns >> it to the task via pointer. When the worker task finishes dealing with the >> item it calls to a protected object's procedure to queue the item back. > > That's how it works now - I forgot to mention that my list is wrapped in > a protected object, otherwise it wouldn't work :) > My idea of using a circular list is to call Delete and Append only when > new node joins the system or an old one leaves. During normal operations > a task will request new unit of work without deleting it from the queue. Why? What I don't understand is why removing from a queue should deallocate anything. It might be an artefact of Ada.Containers, but in general case it is not unnecessary. Removing just means that it is the task who will hold the item. Technically the item will be either in no list or in the list of one item long owned by the task. You have one list of items waiting for service and n lists of items being serviced, where n = number of worker tasks. Interlocking is only necessary when you move an item from list to list. > It will be only marked as "currently in use". Other tasks will skip > this node - Next_To_Service pointer will move clockwise skipping nodes > that are serviced at the moment. If you do this you would not need any lists, just a ring buffer of items. With a relatively small number of worker tasks the overhead of skipping items in use is not that big, but you will have another potential problem: unbalanced servicing. When an item was serviced a bit longer than its neighbours, it might miss its train of servicing. What is worse it could become a systematic problem for some items with a huge impact in result. Doubly-linked lists do not have this problem, while removing and inserting overhead is just negligible. You can shuffle items between lists very efficiently. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de