From: Eris Discordia <eris.discordia@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] critique of sockets API
Date: Thu, 11 Jun 2009 08:07:19 +0100 [thread overview]
Message-ID: <4D2A8C4D5A4A12CCFA550A85@[192.168.1.2]> (raw)
In-Reply-To: <ee551f922579dab6a4041baf3199f3c1@quanstro.net>
> i don't think i understand what you're getting at.
> it could be that the blog was getting at the fact that select
> funnels a bunch of independent i/o down to one process.
> it's an effective technique when (a) threads are not available
> and (b) processing is very fast.
This might help: what he is getting at is probably the question of why not
make possible network applications that consist of a bunch of callbacks or
a mix of callbacks and listener/worker threads. Windows implements both
synchronous and asynchronous I/O. Threads are available. Callbacks, too, as
well as message queues. Ideally, it is the programmer's informed choice
based on their understanding of their application's priorities whether to
use callbacks, listener/worker threads, message queues, or a combination.
Someone may find it worth the effort to compare these approaches on a
platform that provides both. (COM is notorious for implementing things
through callback that get some wrapping of one's head around them before
making sense.)
--On Tuesday, June 09, 2009 20:07 -0400 erik quanstrom
<quanstro@quanstro.net> wrote:
> On Tue Jun 9 19:22:39 EDT 2009, bpisupat@cs.indiana.edu wrote:
>> Well, select() or alt might or might not be required depending on
>> whether you want your thread to wait till the read operation waiting
>> for data from the network completes.
>
> your thread will always wait until any system call completes;
> they're all synchronous all the time. if you want your application
> to do something else at the same time, you're going to need two
> threads and a synch device (like a lock + shared memory or a channel).
>
>> read()->process()->read()... alternating sequence of operations that is
>> required, wherein the application has to explicitly go fetch data from
>> the network using the read operation. To borrow text from the paper:
>> <snip>
>> The API does not provide the programmer a way in which to say, "Whenever
>> there is data for me, call me to process it directly."
>> </snip>
>
> i don't think i understand what you're getting at.
> it could be that the blog was getting at the fact that select
> funnels a bunch of independent i/o down to one process.
> it's an effective technique when (a) threads are not available
> and (b) processing is very fast.
>
> perhaps you think this is doging the question, but the cannonical
> plan 9 approach to this is to note that it's easy (trivial) to have a n
> reader threads and m worker threads s.t. i/o threads don't block
> unless (a) there's nothing to i/o, or (b) the workers aren't draining
> the queue fast enough; and s.t. worker threads don't block
> unless (a) the i/o threads can't keep up. in this case, there is no
> work to do anyway. consider these two types of threads;
> let mb be a pointer to a message buffer.
>
> thread type 1
> for(;;)
> mb <- freechan
> read(fd, mb->wp, BUFSIZE);
> mb -> fullchan
> thread type 2;
> for(;;)
> mb <- fullchan
> do stuff
> mb -> freechan
>
> if your server issues responses, it's easy to add thread type 3.
>
> as you can see, this is a simple generalization of your case. (if we
> have a queue depth of 0 and one thread 1 and one thread 2,
> we will get your loop.) yet there should be no waiting.
>
>> The question was meant to ask as to how easy it is to programmatically
>> use the filesystem interface in a multi home network. But I agree that
>> support for multiple network interfaces in Plan9 is way superior.
>
> i think the answer to your question is that programs don't care.
> programs that take a cannonical network address are just as
> happy to accept /net/tcp!www.example.com!http as they are to
> accept /net.alt/tcp!www.example.com!http. for a short while
> i ran a 10gbit network on /net.10g.
>
> - erik
>
next prev parent reply other threads:[~2009-06-11 7:07 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.998.1244574121.1513.9fans@9fans.net>
2009-06-09 23:20 ` Bhanu Nagendra Pisupati
2009-06-09 23:24 ` J.R. Mauro
2009-06-09 23:33 ` Devon H. O'Dell
2009-06-10 3:33 ` Gary Wright
2009-06-10 0:07 ` erik quanstrom
2009-06-10 0:34 ` erik quanstrom
2009-06-11 7:07 ` Eris Discordia [this message]
[not found] <mailman.1.1244808001.26495.9fans@9fans.net>
2009-06-13 1:39 ` Bhanu Nagendra Pisupati
[not found] <b0a72b5826eb44300d3603f585859910@quanstro.net>
2009-06-11 14:54 ` Eris Discordia
2009-06-11 18:24 ` erik quanstrom
2009-06-11 21:21 ` Eris Discordia
2009-06-11 23:41 ` erik quanstrom
2009-06-12 4:32 ` Paul Lalonde
2009-06-12 7:19 ` Eris Discordia
[not found] ` <D9FE8C51EE2D568C05E555DD@192.168.1.2>
2009-06-11 23:34 ` Devon H. O'Dell
2009-06-12 7:21 ` Eris Discordia
2009-06-11 12:16 erik quanstrom
[not found] <mailman.1.1244635201.19660.9fans@9fans.net>
2009-06-10 23:46 ` Bhanu Nagendra Pisupati
[not found] <mailman.1007.1244590421.1513.9fans@9fans.net>
2009-06-10 22:50 ` Bhanu Nagendra Pisupati
2009-06-11 12:34 ` erik quanstrom
-- strict thread matches above, loose matches on Subject: below --
2009-06-09 18:49 Bhanu Nagendra Pisupati
2009-06-09 18:59 ` erik quanstrom
2009-06-09 22:11 ` Russ Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='4D2A8C4D5A4A12CCFA550A85@[192.168.1.2]' \
--to=eris.discordia@gmail.com \
--cc=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).