[bind10-dev] Non-preemptive threads as an alternative to events?
Shane Kerr
shane at isc.org
Mon Mar 14 13:24:56 UTC 2011
Francis,
On Mon, 2011-03-14 at 13:09 +0000, Francis Dupont wrote:
> > The drawback is that you can only use a single CPU at a time, since
> > you are only ever executing a single thread at a time. But that works
> > okay for servers that mostly spend their lives waiting on network I/O.
>
> => if you can use a single CPU at a time it is simpler to forget
> threads directly, isn't it?
The idea is that code that looks like this:
--------------------------------------------------------------------
foo()
{
setup();
while (read_data()) {
some_processing();
write_data();
}
teardown();
}
--------------------------------------------------------------------
Is easier to read than code that looks like this:
--------------------------------------------------------------------
foo()
{
setup();
start_read_data(foo_data_read);
}
foo_data_read()
{
if (read_data) {
some_processing();
start_write_data(foo_data_written);
} else {
teardown();
}
}
foo_data_written()
{
start_read_data(foo_data_read);
}
--------------------------------------------------------------------
Of course this only makes sense if the amount of processing done per I/O
event is very small. This is the case for DNS when it is acting as
authoritative, recursive, master or slave. It is not the case when doing
certain DNSSEC actions like signing a zone.
In BIND 10 we already have the ability to relatively easily split off
functionality into separate processes when we want to scale across CPUs.
In the case of events, we're scaling a number of events across a single
CPU. The question is whether this actually makes sense.
--
Shane
More information about the bind10-dev
mailing list