Reply to Re: [PHP] Getting the process ID

Your name:

Reply:


Posted by trlists on 03/25/05 19:01

On 25 Mar 2005 Joshua Beall wrote:

> P1: "Does token.status = 'locked' WHERE key=$key ?"
> P2: "Does token.status = 'locked' WHERE key=$key ?"
> P1: {Receives negative response}
> P2: {Receives negative response}
> P1: Updates token.status. = 'locked' WHERE key=$key
> P2: Updates token.status. = 'locked' WHERE key=$key

The problem here is that the check / lock operation has to be "atomic",
that is you can't let a second process check or lock the resource while
the first is in the process of locking it. This is a basic issue for
any kind of semaphore, you have to be able to do an atomic "test and
set" or you get problems exactly as described above.

If it's a MySQL table then to me the simple solution is to use a LOCK
TABLES then test and set the token stored in the database, then UNLOCK
TABLES. But that might be a bit "expensive" in terms of overhead, and
you can probably find a way to do it with local files as well. Also
the shared memory functions look like they could be useful in this
regard, if supported on your platform.

--
Tom

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация