Re: [PHP4BETA] how does the ZTS work / where are the mutexes?
| From: | Zeev Suraski | Date: | Mon, 16 Aug 1999 16:22:45 +0000 |
| Subject: | Re: [PHP4BETA] how does the ZTS work / where are the mutexes? | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-3453@lists.php.net to get a copy of this message | ||
Long one :)
In essence, a summary of all of the answers below is that PHP does not take advantage in any way of multithreading; Its multithreaded mode is simply designed to protect against clashes with global variables. The memory manager tries to tranparently emulate a multi-process environment.
At 16:19 16/08/99 , Thies C. Arntzen wrote:
hi, got a few questions regarding the thread-save-mode: 1. how many plist are there (ZTS-mode)? in theory there should be only one, right?There's one per thread. Having just one for the entire process would change semantics, and may not work with 3rd party libraries that are thread safe (they would expect certain local storage to be available, and it won't be).
2. all the mutexing is done in zend_hash_add_or_update and friends, right?No, none are. Mutexing is done in TSRM - take a look at it and you'll see. Basically, you must mutex each time you obtain a global resource (*_FETCH()) and when a new thread is created.
3. what happens if 2 requests try to add a persistend connection at the same time - or - should we 1st add to plist and then open the connection, or 1st open the connection and then add to plist?It should be no different from multiprocess mode, because there's no different semantics for the persistent list there.
4. when & who calles the plist destructors in ZTS mode?The thread local storage destructor.
5. is all the MUTEX stuff in ext/*.c obsolete? (same goes for #ifdef THREAD_SAFE) - and should we *slowly* remove that codeYes. When removing, it'd be wise to replace the code with TSRM-compatible code; The places that contain those #ifdef's give you a good direction on where to look for thread safety issues.
6. can you think of any place where we need to do mutexing ourself?There shouldn't be such a place, unless you will be juggling global resources not through TSRM (not recommended).
7. last but not least, is ISAPI the only testbed fot the ZTS stuff?Yes. Zeev -- Zeev Suraski <zeev@zend.com> http://www.zend.com/ For a PGP public key, finger bourbon@netvision.net.il