Advantages of a large number of threads cf other approaches?
Scott Lystig Fritchie
Thu Feb 19 03:41:03 CET 2004
>>>>> "sh" == Sean Hinde <> writes:
sh> I just carried on reading about such issues, and it seems that the
sh> dup system call might offer some assistance with setting this
sh> whole thing up. I don't really get how you are supposed to pass on
sh> the new file descriptor to another process though, and the
sh> descriptions I have read
sh> (e.g. http://nscp.upenn.edu/aix4.3html/aixprggd/genprogc/fdescript.htm
sh> ) are a little hard for an Erlang only sort of guy to comprehend..
The king of all references on the subject is (IMHO) W. Richard
Steven's _UNIX Network Programming_. Unless you consider it to be the
more updated W. Richard Steven's _Advanced Programming in the Unix
Environment_, which is a bit newer.
I just tore our house upside-down looking for _APUE_, but I couldn't
find it, which makes me sad, because good reference books like _APUE_
should always be within easy reach. As a consolation prize, I found a
description of the System V-style file descriptor passing in _UNIX
System V Network Programming_ by Stephen A. Rago. Steven's books
describe both the System V-style and BSD-style techniques.
The source code to all of the examples in those two Steven's books can
be found at ftp://ftp.uu.net/published/books/.
Both sides open a pipe.
The sending process uses an ioctl(2) call to pass the
descriptor across the pipe.
The receiving process uses ioctl(2) to get the descriptor.
Both sides open a UNIX domain socket (pipe OK too?).
The sending process formats a magic "struct msghdr" structure,
then sends it using sendmsg(2) across the UNIX domain socket.
The receiving process uses recvmsg(2) creates a similar
structure and uses recvmsg(2) to get the descriptor.
More information about the erlang-questions