Date: Thu, 14 Nov 1996 13:22:32 +0100 (MEZ) From: "Hr.Ladavac" <lada@ws2301.gud.siemens.co.at> To: exidor@superior.net (Christopher Masto) Cc: hackers@freebsd.org Subject: Re: Programming technique for non-forking servers? Message-ID: <199611141222.AA205274152@ws2301.gud.siemens.co.at> In-Reply-To: <199611131705.MAA10785@nimbus.superior.net> from "Christopher Masto" at Nov 13, 96 12:05:50 pm
next in thread | previous in thread | raw e-mail | index | archive | help
E-mail message from Christopher Masto contained: > Andrew Stesin writes: > > > Is forking on FreeBSD all that bad? > > > > Of course, no! > > > > But I have an impression that there's easier > > to implement locking of shared memory and file > > resources inside a single-process server than > > with some kind of IPC. There is SysV IPC around, > > but it has it's limitations. Using mmap() as a shared > > memory pool? isn't so clear and transparent for me (at least > > now), and generally isn't documented; so the question > > remains opened, that's why I'm asking about > > where a Fine Manual resides which should be read. > > This reminds me of a related thing that's been nagging me since I > first started writing Unix programs about 5 years ago. Occasionally > (more often recently) I'm working on something that screams for a > couple of cooperating processes.. coming from the Amiga world, this > seems very natural, and on the Amiga it was very simple. One process > opens up a "message port", and another process sends messages to it. > The closest thing I have seen is creating a socket in the Unix > domain.. but this doesn't seem very popular, so I get the feeling it > isn't often the right answer. > > I suppose part of the problem is that I've learned mostly from man > pages, so I haven't read any of the canonical books on Unix or network > programming. > > Of course, this is probably not the most appropriate place in which to > whine about this. It's okay, I'd say. Because, what you've used to call processes on an Amiga we call threads, i.e. threads of execution within single memory space. BTW, POSIX threads are implemented in -current and probably 2.2, and there is a port for 2.1 (called pthread or something like that). Yes, threaded programming vastly simplifies the task of building a non- forking non-blocking server. Try to find some info on pthreads. Essentially, you can attach a listener thread to every opened fd, and then decide whether you wish to employ worker threads or do the work on the listener thread. Naturally, threads are pre-emptively scheduled in FreeBSD implementation. You can take a look at: ftp://gatekeeper.dec.com/pub/DEC/SRC/research-reports/SRC-035.ps.Z for "An Introduction to Programming with Threads" ftp://opcom.sun.ca/pub/doc/solaris/pthreads_comparison.ps.Z "pthreads and Solaris Threads: A Comparison of Two User Level Thread APIs" > > And while I'm at it.. I miss ARexx. I keep wishing for something like > a Perl that runs as a daemon and provides unified scripting services to > other programs. > -- > Christopher Masto . . . . Superior Net Support: support@superior.net > chris@masto.com . . . . . Masto Consulting: info@masto.com > > On Wisdom, Congressional: > That's the most unheard-of thing I ever heard of. > - Senator Joseph McCarthy, talking about a witness's testimony >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199611141222.AA205274152>