[jdev] Why are we doing math on socket handles?
Bresler, Jonathan
Jonathan.Bresler at usi.net
Tue Apr 5 09:08:09 CDT 2005
<quote>
There just seems something fundementally flawed about using the handle
values the OS gives you as anything meaningful - except possibly for a
dictionary lookup. I also have a problem with using signals as process
control, but I can easily state that particular bias is due to my windows
background.
</quote>
By default on may systems the size of the file handle arrays passed to select() are 1024 elements. There are three arrays: read, write, execptional conditions. One sets the contents of the arrays to indicate when one is interested in the any combination of the three conditions on any mix of file handles (for example, read on fd 0,4,65; write on 1,2,66; exceptions on 65,66). One can then set max_fd for this call to select() to indicate to the OS that there is no need to check the arrays past the 67th element (fd 66 is element 67).
Alternatively, one can not do this and always set max_fd to 1024. In apps that do a lot of socket I/O there is a measureable performance difference.
Additionally, on some systems one can go well beyond 1024 and setting max_fd becomes commensurately more important.
If Windows ignores the max_fd parameter then it must act pessimally and check the entire array for all conditions. It’s a choice of the writers of the OS.
<quote>
After searching the 2s6 code I don't see the use of select or the wrapped up
mio_select anywhere. Did I miss something? I think this would suggest you
aren't gauranteed particular handle values under any OS.
</quote>
The code is written in such a manner that you must be fluent in expanding C macros. You can run the mio/mio.c file thru "gcc -E" to have the preprocessor expand the macros for you. You will want to search for specific strings in the output, it will be quite verbose as all the include files are....well, included.
The magic you seek is in MIO_CHECK. Understand it and when mio_run() gets called. Notice that each mio_t has its own highfd which is used as input to the maxfd parameter to select().
Jonathan
-----Original Message-----
From: jdev-bounces at jabber.org [mailto:jdev-bounces at jabber.org] On Behalf Of Tim Anderson
Sent: Monday, April 04, 2005 6:07 PM
To: 'jdev at jabber.org'
Subject: RE: [jdev] Why are we doing math on socket handles?
<quote>
Perhaps we can drop the sarcasm. Surely they are enough warts on all of
us To spend the rest of the day pointing them out.
</quote>
OK, that was probably uncalled for. I tend to get more than my fair share of
grief simply because I don't spend my every waking hour tweaking the Linux
kernel or reveling in sed scripts.
<quote>
Maxfd is used in select() to tell the operating system the highest
numbered Fd that interests you in __this__ particular call to select()
</quote>
Windows ignores this particular number in it's calls to select so there
isn't much I can do in that regard.
After searching the 2s6 code I don't see the use of select or the wrapped up
mio_select anywhere. Did I miss something? I think this would suggest you
aren't gauranteed particular handle values under any OS.
There just seems something fundementally flawed about using the handle
values the OS gives you as anything meaningful - except possibly for a
dictionary lookup. I also have a problem with using signals as process
control, but I can easily state that particular bias is due to my windows
background.
Tim
#ifdef _WINDOWS_PROGRAMMER_
#include <stereotypical unix programming nerd jokes.h>
#else
#include <stereotypical windows programming nerd jokes.h>
#endif
_______________________________________________
jdev mailing list
jdev at jabber.org
http://mail.jabber.org/mailman/listinfo/jdev
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.859 / Virus Database: 585 - Release Date: 2/14/2005
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.859 / Virus Database: 585 - Release Date: 2/14/2005
More information about the JDev
mailing list