From owner-freebsd-hackers Thu Nov 14 04:24:25 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id EAA05063 for hackers-outgoing; Thu, 14 Nov 1996 04:24:25 -0800 (PST) Received: from zwei.siemens.at (zwei.siemens.at [193.81.246.12]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id EAA05052 for ; Thu, 14 Nov 1996 04:24:22 -0800 (PST) Received: from sol1.gud.siemens.co.at (root@[10.1.143.100]) by zwei.siemens.at (8.7.5/8.7.3) with SMTP id NAA00862 for ; Thu, 14 Nov 1996 13:23:06 +0100 (MET) Received: from ws2301.gud.siemens.co.at by sol1.gud.siemens.co.at with smtp (Smail3.1.28.1 #7 for ) id m0vO0pX-00021gC; Thu, 14 Nov 96 13:23 MET Received: by ws2301.gud.siemens.co.at (1.37.109.16/1.37) id AA205274152; Thu, 14 Nov 1996 13:22:32 +0100 From: "Hr.Ladavac" Message-Id: <199611141222.AA205274152@ws2301.gud.siemens.co.at> Subject: Re: Programming technique for non-forking servers? To: exidor@superior.net (Christopher Masto) Date: Thu, 14 Nov 1996 13:22:32 +0100 (MEZ) Cc: hackers@freebsd.org In-Reply-To: <199611131705.MAA10785@nimbus.superior.net> from "Christopher Masto" at Nov 13, 96 12:05:50 pm X-Mailer: ELM [version 2.4 PL24 ME8a] Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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 >