Date: Thu, 15 Apr 1999 17:30:10 +0200 (MET DST) From: Luigi Rizzo <luigi@labinfo.iet.unipi.it> To: cracauer@cons.org (Martin Cracauer) Cc: avalon@advicom.net, freebsd-hackers@FreeBSD.ORG Subject: Re: Programming Resources Message-ID: <199904151530.RAA13015@labinfo.iet.unipi.it> In-Reply-To: <19990415193106.A6631@cons.org> from "Martin Cracauer" at Apr 15, 99 07:30:47 pm
next in thread | previous in thread | raw e-mail | index | archive | help
> > Does anyone have any useful links/ftp sites/books (etc.) for those of us > > new to multi-threaded programming (for daemons, etc.)? Obviously, ... > If you aren't already set for threading, you should also consider the > classic fork()/pipe()-based concurrency scheme of UNIX > systems. Steven's "Advanced Programming in the UNIX Environment" is > the cannonical best choice here. I generally prefer it over threads > for various reasons and most daemons on FreeBSD use it as well. as another alternative to threads, in many cases i also tend to use a single process looping around a select(), and structure the handling of each socket as a state machine, doing non-blocking actions at once and returning to the select when a blocking calls is about to be made. For some types of servers (e.g. www, multi-user talk daemons, etc.) this works quite nicely because most of times there is little processing involved between I/O calls, and restructuring the <sequential> code in a way that can be put into the main loop almost only requires to replace read() and write()'s with things like state = THE_NEW_STATE ; break ; case THE_NEW_STATE : (if you know what you do, that is...) cheers luigi -----------------------------------+------------------------------------- Luigi RIZZO . EMAIL: luigi@iet.unipi.it . Dip. di Ing. dell'Informazione HTTP://www.iet.unipi.it/~luigi/ . Universita` di Pisa TEL/FAX: +39-050-568.533/522 . via Diotisalvi 2, 56126 PISA (Italy) -----------------------------------+------------------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199904151530.RAA13015>