Re: phpthreads - hints anyone...

From: Date: Thu, 01 Aug 2002 00:57:10 +0000
Subject: Re: phpthreads - hints anyone...
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-86399@lists.php.net to get a copy of this message
Shane Caraveo wrote:
Alan Knowles wrote:
Im looking at adding threading to php, (for the cgi/cli stuff).. The story so far: I've created an extension which diverts all zend_execute calls into the extension -> phpthreads_execute. this function is a copy of zend_execute with a few modifications - to copy & restore things like EG(active_symbol_table); - to malloc lock and unlock the execute loop and release on each opcode.
Ouch. While it's an interesting way to deal with the issue, I think this will be way too slow, and maintenance will be hard (keeping up with changes in the real zend_execute, and zend engine in general).
Plan A was just to get something that worked - even if it was crude and nasty... :) Agreed - there are lots of issues with this method.. timesliceing and yeilding if the application is locked most of the time is problematic.
As in a couple other responses, the way this needs to be implemented has been hashed out, largely based on how the same problem is solved in Perl (there is a remarkable amount of simularity between PHP and Perl at some levels). If you're interested, lets talk.
- do we have to do it based on perl - their web site is as easy to comprehend as the language - I spent 1/2 hour trying to find any source code or CVS server and failed :) ok - hints would be good.. - pythons source for threading has a url... I'm guessing this generaly means a) turning on php's tsrm stuff. b)on the pthread_create(): copy the memory address of the function/class tables between threads. (eg. so they share the same data). malloc lock any changes to the function/class table = eg. the compiler calls.. do the call_user_func_ex roughly as per before... c) work out a sharing method for variables... regards alan
Shane


« previous php.dev (#86399) next »