NYCPHP Meetup

NYPHP.org

[nycphp-talk] thread-safety analysis...

Vugranam Sreedhar vugranam at us.ibm.com
Sun Oct 22 07:23:53 EDT 2006


Thanks for the explanation...This definitely clarifies many things to me.
Now supposing PHP 7 or greater decides to become multithreading (as Java)
What do you think will be the main issues in the legacy PHP3 to PHP6 with
respect to multithreading ;-)

With regards,

Sreedhar

-------------------------------------------------------------------------------------------------------------------

Research Staff Member
TJ Watson Research Center
T/L 863-7325
Ext: 914-784-7325



                                                                           
             "Hans Zaunere"                                                
             <lists at zaunere.co                                             
             m>                                                         To 
             Sent by:                  "'NYPHP Talk'"                      
             talk-bounces at list         <talk at lists.nyphp.org>              
             s.nyphp.org                                                cc 
                                                                           
                                                                   Subject 
             10/21/2006 10:04          Re: [nycphp-talk] thread-safety      
             AM                        analysis...                         
                                                                           
                                                                           
             Please respond to                                             
                NYPHP Talk                                                 
             <talk at lists.nyphp                                             
                   .org>                                                   
                                                                           
                                                                           





Hi,

Vugranam Sreedhar wrote on Saturday, October 21, 2006 6:39 AM:
> I have studying thread-safety issue with PHP and Apache2.  I know PHP
> does not have a thread model (like Java). I cannot seem to find real
> document/code
> that clearly explains the problem. I am looking at building tool that
> will scan PHP code and tell me whether it is thread-safe or not.
> Would anyone be interested in such a tool ;-)

Others on this list can perhaps provide more detail, but here's a run
down...

PHP cannot do threading itself - it can only fork().  However, PHP's core
itself can be compiled to run in a threaded environment (for instance under
Apache 2's various MPMs).  So PHP itself isn't creating threads - Apache is
handling user requests in a threaded manner, which in turn makes PHP run in
a threaded way.

The problem really is not thread safe code written in the PHP language, but
rather the environment in which PHP runs in.  Now PHP can be compiled for
thread safety (TSRM, for instance http://us2.php.net/tsrm).  However,
because PHP is often linked against so many external libraries
(gd/jpeg/xml/etc) it cannot be considered safe to execute in a threaded
environment.  This is the real problem and one of PHP's greatest strengths
and unfortunate faults.

So, writing an application that scans PHP code for thread safety wouldn't
be
useful.  However, writing an application that would scan the C code of the
libraries used in PHP's extensions, would be of great value - then we could
determine which PHP configuration combinations are thread safe, and which
are not.  For instance, I had once run PHP only with the MySQL and Oracle
extensions compiled, under Apache 2 with threading - it was stable for
years.  Rasmus had once started to document which libraries were thread
safe
and which were not, but I think it hasn't been actively maintained.

Hopefully this somewhat clarifies a confusing issue.

---
Hans Zaunere / President / New York PHP
   www.nyphp.org  /  www.nyphp.com


_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php





More information about the talk mailing list