On Thu, 2002-08-01 at 04:43, Alan Knowles wrote:
> >
> > It's not about looking at the perl code, that will tell you nothing 
> > unless you know perl internals.  It's about the way the interpreter 
> > works, some of the architecture, that is simular to PHP.  In PHP, 
> > threads are isolated, kind of like seperate processes, but in threads.
> 
> 
>  From my understanding they are 'forced to be isolated' by the TSRM 
> stuff.  which looks like it stores globals in something like an 
> associated array ( thread id => global c variable - eg. compiler_globals 
> etc.), when ZTS is enabled..
> 
> > Everything in PHP works that way, so in creating threads for php 
> > scripts, you have to have a seperate interpreter.  Then you have to 
> > create a "bridge" between the threads for shared variables.  shmop 
> > comes close to what is needed, but not close enough.
> 
> the real use of the threading I guess is for people who want to write 
> tcp servers, or desktop gtk apps.
> 
> Thoughts on accessing 'threaded shared vars'
> ------------------------------------------------------------
> $_THREADVAR['gtktext'] type..
> 
> php_threads_malloc_lock();
> $_THREADVAR['gtktext']->add_text('some data ouput');
> php_threads_malloc_unlock();
> 
> this would I guess involve rather heavy changes to the ZE engine to 
> recogize an lock/unlock, copy (rather than refcount) etc. variables that 
> where threaded..
> 
> 
> Threaded objects???

Yes, if you created an overloaded object that handled the sharing of
data there would be no need to modify the engine. Instead of using
methods, you could also use property offsets.

Since an overloaded object is given both read and write hooks, you 
can improve performance by having both shared(read) and exclusive(write)
locks. These locks could even be on a per property basis.


> I guess the other consideration is to have thread variable objects..
> $threadvar  = new Thread_Var();
> $threadvar->setNewObject('mywidget','GtkWindow');
> $threadvar->set('mywidget',$gtkobject);
> $var = $threadvar->get('mywidget');
> $var = $threadvar->getArray('key','val');
> $threadvar->callMethod('mywidget', 'add_text','something');
> 
> obviously copying and accessing these would probably be easier to cope 
> with ( without having to modify heavily the zend engine) -  we could do 
> 'real' copying on the data, rather than refcounting them. and reduce the 
> headaches...
> 
> > You're much closer to what needs to happen now.  But you cannot simply 
> > point to the memory for another thread.  Doing that will cause 
> > problems like you are running into.  You actually have to copy a bunch 
> > of stuff so each thread is completely independent.
> 
> Do you mean we will have to really physically copy the all theopcode 
> data from one thread to another?

Yes, since there are multiple interpreters, they must be synchronized.
(This way they are all allowed to access the POST GET SERVER vars) 


-Jason



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to