Re: Can a script run twice?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 24, 2006 12:45 am, Lester Caine wrote:
> I found while trying to track things. The original problem *IS* that
> PHP
> can run two copies of a script in parallel and the second copy does
> NOT
> see the 'locking' in place on the first copy. I had always thought
> that
> PHP was sequential, but I'm not so sure now.

PHP can run as many in parallel as there are Apache children, not just 2.

You have to always assume that there are N copies of your script
running in parallel, where N is httpd.conf MaxChildren (or whatever it
is)

The Operating System can, and will, "swap" in and out of your N PHP
scripts at any point it feels like it in the middle of your code.

Nothing is sequential nor atomic unless it is documented as atomic.

You can prove this rather quickly with some http://php.net/sleep and
http://php.net/error_log and http://php.net/getmypid calls and many
browsers open, and just hitting re-load really really fast.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux