SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict bronze trophy
    Join Date
    Apr 2013
    Location
    Ithaca
    Posts
    351
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)

    Why is PHP not thread safe?

    Well a while ago I requested that pthreads be integrated with PHP in the next version, looks like its not gonna happen and the primary reason is that PHP is not thread safe.
    https://bugs.php.net/bug.php?id=65797&edit=2

    But I dont understand why the default way PHP is installed/bundled on Unix system is not thread-safe, anyone mind elaborating? Also lets say if I run my own PHP on a dedicated hosting environment and that the PHP can be customized, how can I make PHP thread-safe? Or is it not achievable?

  2. #2
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    66 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by Hall of Famer View Post
    Well a while ago I requested that pthreads be integrated with PHP in the next version, looks like its not gonna happen and the primary reason is that PHP is not thread safe.
    https://bugs.php.net/bug.php?id=65797&edit=2

    But I dont understand why the default way PHP is installed/bundled on Unix system is not thread-safe, anyone mind elaborating? Also lets say if I run my own PHP on a dedicated hosting environment and that the PHP can be customized, how can I make PHP thread-safe? Or is it not achievable?
    Well what is being said here, is that the DEFAULT installation is not thread safe. If you go to the downloads page, you will see two options, thread safe and non thread safe. But in reality, thread safe isnt even truely thread safe (I have not looked too far into pthreads as it was fairly new when I was researching). Think about when PHP was developed and what for. It's hard to conceive that PHP would ever have a need to be thread safe, and now the language is too old / far along / messed up to allow for it to truely be thread safe without a full re write (which will not happen). If you want basic "thread safe" installation, goto the downloads page and install the thread safe version of php, then install pthreads using pecl.

    I too was annoyed with the lack of ability to create threads or at the very least processes with the ability to exchange information between them easily. I've since begun moving away in favor of other languages. PHP definitely has its place (for now) but like every language, it has short comings and situations in which it's not best suited for, threaded operations is close to that line.

    May I ask what type of projects you are working on that has you interested in threading?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •