Re: threads package status

From: Date: Mon, 19 Jul 2004 14:16:25 +0000
Subject: Re: threads package status
References: 1 2 3  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-980@lists.php.net to get a copy of this message
> that`s sad :( my thesis is based on making php to use threads somehow :] You're welcome to have a go at making the threads extension better; it's just that it will be hard if you don't have any prior knowledge of the zend engine, TSRM and php internals. > i saw your name along threads package commiters, I don't recall doing anything more than some build system work. > so maybe you could say if > there is something difficult with implementing simple threading pool > extension like that: array containing php callbacks guarded by mutex, > threads lock on this mutex, producer adds callbacks to the array. threads do > simple fetching from array and call_user_func(). is it doable in php? what > kind of traps do you see in this solution? The problem is that, in a thread safe build (zts), all PHP globals are maintained per-thread via TLS. If you create a new thread, it is not associated with any PHP state and will crash. If you build a non-thread safe build and spawn threads you won't have that problem, but you will have the problem of PHP being completely ignorant of threads and you'll get into all kinds of synchronization (or lack thereof) issues, and crash. The threads extension contains a number of hacks to try to work around this. The problem is that they are hacks and that the real solution is changing the engine, and that is not going to happen any time soon. --Wez.

« previous php.pecl.dev (#980) next »