FAQ

ivan.prostran@alterbox.hr wrote:
The actual question/s :

The code below is some simple example, what I am interesting in, is does zend eval work safe in
multi threading environment and do we need to write some special code into php extensions to achiev mt safety.

---- 1) Php extensions have have an static global data, do I need to protect those with mutexes while running in multithread app.
How to handle this stuff.
If you're running in a multi-threaded environment, you must configure
PHP using the --enable-maintainer-zts option. This switches PHP to use
TLS keys to access its global state.

You don't need mutexes around PHP execution because the global state is
bound to the thread on which it is initialized; you cannot manipulate
the state from outside the thread on which it was set up.
---- 2) What about Zend evaluation, in other words public php vars which are available through all scripts that includes those ... is this too thread safe..

I presume that anything enclosed : into

PHP_EMBED_START_BLOCK(argc, argv);


zend_eval_string(phpCodeBuff1, NULL, "Embedded code" TSRMLS_CC)==FAILURE) ;
zend_eval_string(phpCodeBuff2, NULL, "Embedded code" TSRMLS_CC)==FAILURE) ;
zend_eval_string(phpCodeBuff3, NULL, "Embedded code" TSRMLS_CC)==FAILURE) ;

//phpcode phpCodeBuff3 sees all public wars from 1,2 .....
// what about paralel thread running the same php source... and php extension ...

PHP_EMBED_END_BLOCK();

should be thread safe while runs in multi thread environment...
Provided that you don't do any of that stuff on a different thread, yes,
it is safe.

Please ask further questions on the internals@lists.php.net list.

--Wez.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedDec 31, '04 at 5:11p
activeDec 31, '04 at 5:11p
posts1
users1
websitephp.net

1 user in discussion

Wez Furlong: 1 post

People

Translate

site design / logo © 2022 Grokbase