Mutual exclusion with semaphore - implementation found in the Web.