Of course you know about LOCK TABLE as a way of preventing multiple access to the same table (e.g. when performing a series of updates). But if your applications are co-operating with one another there is a much more efficient way.

Code:
function db_lock($lockname, $timeout="1")
{
$result = FALSE;
$query  = "SELECT GET_LOCK(\"$lockname\", $timeout)";
$q 	= safe_query($query);  
// ("SAFE_QUERY" IS MY FUNCTION TO EXECUTE AN SQL-QUERY.)
if ($q)
{
	if ($row = mysql_fetch_array($q, MYSQL_NUM))
		$result = ($row[0] == 1);

	mysql_free_result($q);
};
return $result;
}

function db_unlock($lockname)
{
$result = FALSE;
$query  = "SELECT RELEASE_LOCK(\"$lockname\")";
$q 	= safe_query($query);
if ($q)
{
	if ($row = mysql_fetch_array($q, MYSQL_NUM))
			$result = ($row[0] == 1);

	mysql_free_result($q);
};
return $result;
}
These functions lock and unlock an arbitrary string-value. They do it very efficiently. Your applications agree upon a convention that they'll use in building the strings for different things, when they'll try to lock and unlock them and so forth. This allows you to create much higher throughput because lock-requests that don't have to block one another, don't.