Re(3): Proper time to thread?
Re(3): Proper time to thread?
- Subject: Re(3): Proper time to thread?
- From: Jason Linhart <email@hidden>
- Date: Fri, 31 May 2002 18:31:06 -0400
I believe that some of your assumptions are a little off.
There are two network programming models in Darwin/BSD: blocking threads
and select. Both approaches are very very fast. Using select has been
shown to be a little faster than blocking threads (but just a little). In
many situations either approach will be faster than anything you could do
on OS 9. There are some exceptions to this, but 98% of the time even
fairly bad code on OS X will be close to as fast as (or faster then)
optimal code on OS 9.
I have not seen the OpenTransport glue code, but I strongly suspect that
they are using a thread calling select to trigger notifiers. If so (very
very likely) then using select directly will be faster than going through
the OpenTransport emulation of notifiers.
On OS X, none of this matters much unless you are trying to drive Gigabit
Ethernet at full speed. The networking model is so much simpler to use
than the one on OS 9 that very few applications need to worry about any
of these issues.
The only way to get true interrupt code on OS X is to write a device
driver, and even then you are strongly encouraged to go through a run
loop. Going through a run loop ends up being very similar to a cleanly
written version of blocking threads (with serialization). Apache uses
blocking threads, and achieves very very respectable throughput and
response time.
Don't be mislead by the twisted assumptions OpenTransport has forced on
us over the years. Notifiers on OS 9 were fine, but they only seemed like
the one true way because ever other approach on OS 9 was so slow as to be
almost unusable.
Jason
On 5/31/02 5:39 PM Jens Bauer (email@hidden) wrote:
>
Hi Peter and Quinn,
>
>
>To be honest, I was skeptical of the BSD threaded blocking model
>
>at first. It can't possibly offer the same raw speed as the
>
>interrupt driven notifiers of Open Transport because you have
>
>to wait for the kernel to get around to scheduling your thread.
>
>
This is something I've been thinking about for a while!
>
>
It's possible to use the interrupt-model with Open Transport.
>
+ Open Transport was built on top of BSD.
>
= It must (somehow) be possible to make the same kind of interrupts with
>
BSD ?
>
>
I don't really know how to form the words; but what I'm trying to say is
>
that it should be possible to do a non-threading interrupt-triggered
>
event-handler.
>
>
Maybe this requires modification of the kernel, but let's see, if Open
>
Transport lives in Carbon-space, it would be outside the kernel, and this
>
means it'd be fully possible to implement, even for a developer not
>
working at Apple.
>
>
I like the speed of the notifiers, I like the simplicity of BSD sockets;
>
could we combine them, then I'd be very happy. =)
>
>
(Am I all wrong in my assumption ?)
-----------------
email@hidden
-----------------
Dr. Seuss books . . . can be read and enjoyed on several levels. For
example, 'One Fish Two Fish, Red Fish Blue Fish' can be deconstructed
as a searing indictment of the narrow-minded binary counting system.
-- Peter van der Linden, Expert C Programming, Deep C Secrets
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.