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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e33eec6b5394f9ec X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-08-28 01:56:37 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Multiple linked data structure Date: Thu, 28 Aug 2003 11:03:17 +0200 Message-ID: References: <404ee0af.0308270752.90ac2b6@posting.google.com> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1062060996 10454181 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:41913 Date: 2003-08-28T11:03:17+02:00 List-Id: On 27 Aug 2003 08:52:55 -0700, fjloma@andaluciajunta.es (Francisco Javier Loma Daza) wrote: >I am reading some OS sources (C sources), and I have seen a common >structure, for example: a procces can be waiting on the processor wait >queue, disk queue and network queue. This is implemented by several >next pointer on the respective queue; add a new queue, then add a new >pointer on the task structure, and potentially a new set of queue >operations. In C this can be alleviated by preprocessor tricks, and I >was wondering how to make this in Ada. > >The first option can be to have a generic queue instantiated with the >task record type, but then some combined iteration can be more >complicated. For example, iterating through the processor queue and >quering if it has pending io requests by testing null for some >(network, disk) next pointers. With the separate queue object, it >would be needed to have some bits on the task structure to cache this >information, or simply iterate the correspondings queues ...... > >Have you faced a similar question? Yes. I have flatten the set of queues. > are there a design pattern that >encapsulates and solves efficiently this kind of problems? In fact Ada already has such queues implemented. If you map a scheduling item to an Ada task (and I see no reason why not), then when a task goes after a rendezvous to another task or spins to a protected object, then, in effect, it is placed into a queue. Timed calls you will have for free. As for the question of many queues. One can have one queue for everything and map the "original" queues into the entry point quards. When quards depend on some external things, you can use the requeue statement. Though it could be a bit tricky, especially with the obscure issues of the requeue statement, but the advantage is that you can rely on a well tested and specified implementation. One could object that it should be slow as compared with a manual implementation of multiple queues, but I am not so sure about it. --- Regards, Dmitry Kazakov www.dmitry-kazakov.de