Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys



dyoung%pobox.com@localhost said:
> I think that you mean something like this?
> [...]
>       for (dv = deviter_first(&iter); dv != NULL; dv = deviter_next(&iter))

Yes, or perhaps
(void or status) deviter_init(&iter);
while ((dv = deviter_next(&iter))) {}

This would allow to do something between the init and
traversal, eg adding a filter (don't know whether that
useful...). And it would be almost as concise
as TAILQ_FOREACH(){}.

> I used such an iterator pattern in my recent shutdown patches, but I
> didn't lock, I removed devices, and I walked the list forward, oops! :-)

A possible alternative to disallowing or deferring device
removal could be to declare iterators invalid... Just an idea.

> Perhaps a reader/writer lock is appropriate?

A rwlock(9) would introduce ordering contraints which
can't be fulfilled easily. Imho we need some more lazy
method.

> Perhaps walk the list backwards in the "writer" case?

That's too much assumptions for my taste. They might hold
for now, but if someone changed the internals of the device
list - eg from a linear list to a tree or associative array -,
it would need to be redone.
Device tree walking doesn't happen in performance critical
paths, so we can take the cost of some abstraction.

best regards
Matthias




-------------------------------------------------------------------
-------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich

Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr. Harald Bolt,
Dr. Sebastian M. Schmidt
-------------------------------------------------------------------
-------------------------------------------------------------------



Home | Main Index | Thread Index | Old Index