Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47728 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97360 invoked from network); 1 Apr 2010 23:04:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Apr 2010 23:04:57 -0000 Authentication-Results: pb1.pair.com header.from=dennis.hotson@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=dennis.hotson@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: dennis.hotson@gmail.com X-Host-Fingerprint: 74.125.82.42 mail-ww0-f42.google.com Received: from [74.125.82.42] ([74.125.82.42:56959] helo=mail-ww0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 87/DA-44965-79625BB4 for ; Thu, 01 Apr 2010 18:04:56 -0500 Received: by wwc33 with SMTP id 33so1152735wwc.29 for ; Thu, 01 Apr 2010 16:04:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:received:message-id:subject:from:to:cc:content-type; bh=fJ2CV3FAr8dRveIN7CQFo3EGaFadywpJI8o/wsV8Ock=; b=iLuNBAzyWCdnOotJqYEk01qt7hIB7esQ8N/UzZub1zHVruMTWn8l8rpQ/hMelv/w01 ipTIGN3TqGR78klSVodziwNMZZYsbOAHo66lghK5EvHwM5WFCA5jf5qp0wxo2WhxSlAP awe2/Ie88ct9R8+znxLCv6X5hhglv4GOtQmlI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=QlWAJg5GmeJsChXgAt4ruwKJPvgDsS8C/toh6kTevpbCmmm4EQtmwPX2A9iOPfFsfc jhhew/AzX5mxM9A6TlodC2D9X00LsJsBDoP3ZiiLkk7WEx+S+KnSjcJ3wZaXmjlb+gqY na4A2aU5K7XMOv9JcowzROxO5OnfFlnr0mANA= MIME-Version: 1.0 Received: by 10.216.8.208 with HTTP; Thu, 1 Apr 2010 16:04:52 -0700 (PDT) In-Reply-To: <1941231697.20100401163215@gmail.com> References: <1941231697.20100401163215@gmail.com> Date: Fri, 2 Apr 2010 10:04:52 +1100 Received: by 10.216.86.210 with SMTP id w60mr819323wee.48.1270163092768; Thu, 01 Apr 2010 16:04:52 -0700 (PDT) Message-ID: To: speedy Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=0016e6d99d03f3882b048334e306 Subject: Re: [PHP-DEV] php and multithreading (additional arguments) From: dennis.hotson@gmail.com (Dennis Hotson) --0016e6d99d03f3882b048334e306 Content-Type: text/plain; charset=ISO-8859-1 I use pcntl_fork() for writing parallel multi-process applications and it works pretty well. Also, you can use shared memory queues to pass messages between processes (ie msg_get_queue()). I wrote a little proof of concept library a while ago to demonstrate: http://github.com/dhotson/Phork It's not that complicated... the main part of it is only ~110 lines of code: http://github.com/dhotson/Phork/blob/master/classes/Phork/Process.php Regards, Dennis On Fri, Apr 2, 2010 at 1:32 AM, speedy wrote: > Hello PHP folks, > > I've seen this discussed previously, and would like to add a few > arguments for the multi-threading side vs. async processing, > which I've seen mentioned as a viable alternative: > > 1. Imagine that from time to time, some background processing takes 1 > second of CPU time - w/o multithreading, all your async operations, > like accepting a connection to a socket, aio or others are basically > stalled. So, async is a good approach, but does not work as a magic > wand for all problem spaces. Alternatively, you could fork and then do > the > processing, but then the state syncing of the forked background > processing > results with the main thread requires a whole new protocol / switching > to > interprocess communication, which makes such developments > unnecessarily > hard. Threads exist for a _reason_ not only because they sound cool. > > 2. Without thread support, it is not possible to use multi-core > processing > paradigms directly from PHP - which means PHP relies on external > frameworks for > that feature, which, in a sense, makes it a non-general-purpose > language. > It _could become_ a general purpouse tool, if it had proper > multi-threading > support built-in. > > I, personally, considered developing websockets / nanoserv server > stack with PHP > and bumped into the multithreading limitation - AFAIK it is the only > big feature > separating PHP from the general purpouse languages. Everything else is > well > integrated with lots of external libraries/modules giving rise to > potential rapid > application development while using it. > > Cheers and let me know about your thoughts, and potential core > implementation > issues regarding developing this language feature. > > -- > Best regards, > speedy mailto:speedy.spam@gmail.com > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --0016e6d99d03f3882b048334e306--