comp.lang.ada
 help / color / mirror / Atom feed
From: Dmitry A. Kazakov <mailbox@dmitry-kazakov.de>
Subject: Re: Multiple linked data structure
Date: Thu, 28 Aug 2003 11:03:17 +0200
Date: 2003-08-28T11:03:17+02:00	[thread overview]
Message-ID: <ppfrkvgss830gstkael17kg0359q2fh7pi@4ax.com> (raw)
In-Reply-To: 404ee0af.0308270752.90ac2b6@posting.google.com

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



      parent reply	other threads:[~2003-08-28  9:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-27 15:52 Multiple linked data structure Francisco Javier Loma Daza
2003-08-28  1:31 ` Matthew Heaney
2003-08-28  9:03 ` Dmitry A. Kazakov [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox