From owner-freebsd-questions@FreeBSD.ORG Tue Jan 25 03:55:24 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A323A16A4E3 for ; Tue, 25 Jan 2005 03:55:24 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7122843D41 for ; Tue, 25 Jan 2005 03:55:18 +0000 (GMT) (envelope-from gert.cuykens@gmail.com) Received: by rproxy.gmail.com with SMTP id f1so58870rne for ; Mon, 24 Jan 2005 19:55:18 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=LdEAGrlnAI0XLMhTk37nebsIPmwkjJ9BpAysm0C9Q0yAi9h0/gbtPSemj/i8oPX5FKXhxv+Lh8aZE9PKdTcwSQmsrBlvsIsJQhGT67s4v0Q0FocyUcK3SG8kARS2fZhVjA2n8BhpKWPiz41VxE+zifL4Dv4Mm2wix2E0k5PGVA4= Received: by 10.38.161.42 with SMTP id j42mr25293rne; Mon, 24 Jan 2005 19:55:17 -0800 (PST) Received: by 10.38.74.6 with HTTP; Mon, 24 Jan 2005 19:55:17 -0800 (PST) Message-ID: Date: Tue, 25 Jan 2005 04:55:17 +0100 From: Gert Cuykens To: Mario Hoerich In-Reply-To: <20050125032056.GA11198@Pandora.MHoerich.de> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <20050125032056.GA11198@Pandora.MHoerich.de> cc: freebsd-questions@freebsd.org Subject: Re: php and apache X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Gert Cuykens List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Jan 2005 03:55:24 -0000 On Tue, 25 Jan 2005 04:20:56 +0100, Mario Hoerich wrote: > # Gert Cuykens: > > can somebody explain what the difference is between forks and > > threads > > Nutshell version: fork(2) produces a new process, which may consist > of multiple threads. > > fork(2)ing used to be slightly more expensive, as it creates a new > process with an accompanying process control block (PCB) and > allocates its own memory pages. Threads just use their processes' > data segment and thus share pages. Which basically means one thread > can trash another's data, whereas related processes can not. > > OTOH the time slices handed out by the process scheduler > ("Hey! PID 384! Your turn for the next 20ms!") are further subdivided > by the thread scheduler. Since both thread scheduler and context > switches between threads produce some overhead (storing local data, > instruction pointer and such) threads used to reduce the real CPU > time a process could actually use for its algorithms. > > I said "used to", because this is basically the theory introductory > textbooks on OS design will tell you.[1] There's plenty of ways to > adapt costs, i.e. by making the process scheduler hand out larger > slices to multithreaded processes or employing copy-on-write, which > means that the parent processes' pages are just mapped into the child > process, until the child actually writes to them. Traditionally, > Unices had pretty cheap processes but rather expensive threads. > (Windows, for example, had it the other way around). > > I didn't delve into this for quite a while, so sadly, I can't give > you any details on the current state of things. > > HTH, > Mario > > [1]: > Be warned, this is from the top of my head and it's 4am in the > morning with my bed waiting for me. I just hope I've been at > least *somewhat* coherent... ;) > thx ps can you tell me who is winning at the moment ? The fork or the spoon ? bsd 6 is still a fork right ?