Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79033 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51729 invoked from network); 20 Nov 2014 10:30:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Nov 2014 10:30:38 -0000 Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.215.10 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.215.10 mail.experimentalworks.net Received: from [217.114.215.10] ([217.114.215.10:42036] helo=mail.experimentalworks.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A3/A6-14967-CC2CD645 for ; Thu, 20 Nov 2014 05:30:37 -0500 Received: by mail.experimentalworks.net (Postfix, from userid 1003) id 385E8474F6; Thu, 20 Nov 2014 11:30:53 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on km31408.keymachine.de X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=ALL_TRUSTED autolearn=unavailable version=3.3.2 X-Spam-HAM-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP Received: from [192.168.178.73] (p5DCBD6B1.dip0.t-ipconnect.de [93.203.214.177]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: johannes@schlueters.de) by mail.experimentalworks.net (Postfix) with ESMTPSA id A50F0474F7; Thu, 20 Nov 2014 11:30:50 +0100 (CET) Message-ID: <1416479430.15061.15.camel@kuechenschabe> To: Tigran Bayburtsyan Cc: internals@lists.php.net Date: Thu, 20 Nov 2014 11:30:30 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] PHP SAPI module help From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) Hi, On Tue, 2014-11-18 at 18:08 +0400, Tigran Bayburtsyan wrote: > I need to execute PHP code in some thread of my application and continue > excecution in another. Is is possible to somehow get all global PHP core > hashtables from first thread and restore PHP from that point in another > thread using that hashtables with all generated variables and functions ? PHP works request base. Meaning the idea is to have isolated shared-nothing requests. PHP can run in two modes: 1. In a global environment, or 2. in a threaded environment this is controlled by enabling or disabling ZTS - zend thread safety / TSRM thread-safe resource manager. In the first case you have a global state running one "request" at a time, theoretically this single request context can be accessd by multiple threads while access has to be guarded by some mutex. In the second case you can have multiple requests which separate state. Each of those is bound to a (posix|windows) thread sharing a context in this mode between different threads can't be easily done and requires patching (in non-public code I once created worker threads owning the PHP request and different threads can signal there to bypass, but that's a mess). The probably most simple SAPI using different threads is my pconn SAPI: https://github.com/johannes/pconn-sapi Except for source we don't really have good documentation on all the details. So please try to go through different SAPIs and try to understand them. Specific questions are welcome on this list. johannes