NYCPHP Meetup

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

Paul Houle paul at devonianfarm.com
Sat Oct 21 22:29:15 EDT 2006


Hans Zaunere wrote:
> 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.
>   
    This is also a problem for Perl,  Python and many other languages 
which are advertised as thread-safe.  Java runtimes are threadsafe 
because of a general xenophobia:  the Java runtimes link in a limited 
number of C libraries,  and Java programmers don't really believe in 
linking in C libraries...  Though I have to admit that I've had good 
luck linking Java to Fortran.

    Lacking threads,  the big disadvantage of PHP is that it consumes 
more memory.  Data structures need to be replicated for each copy of 
PHP.  That said,  RAM is getting cheaper,  and PHP is parsimonious in 
it's memory use,  so most of us do just fine running PHP in processes 
instead of threads.



More information about the talk mailing list