Kent Larsson wrote:
Thank you for your answer. I was hoping there were a solution. :-/ It would have been nice as PHP has a large install base and is a quite common element in cheap web hosting solutions. Has anyone else got any more comments or suggestions? In absence of shared memory and threads. What I really must have is some kind of mutex functionality. I will be manipulating files on disk and I don't want two instances to be able to touch the disk at the same time. Is there something I could use for mutual exclusion? If there aren't any dedicated methods, are there 100% reliable workarounds?
If you are looking for shared memory such that one request can then access an object created once (e.g. "primed") and stored for subsequent reuse, then this is totally possible.
Using something like memcached or APC you can access such shared memory etc. Access to APC shared memory is protected using various locking methods, including File Locks (mmap), IPC Semaphores, Spinlocks and PThread Mutexs.
While you cannot run threads in a Web based environment very easily, you can fork child processes: http://uk.php.net/pcntl_fork. I'm not sure I'd recommend this for a web environment tho! Depending what you are doing tho' you may want to run a small "daemon" that listens for connections and spawns off a new process to deal with it via this method. It really depends what you are trying to achieve as all of the timing/locking problems of asynchronous programming are typically something I would try and avoid in a web/scripting environment.
HTHs Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mandriva Linux Contributor [http://www.mandriva.com/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php