Explain the difference between a mutex and a semaphore, and describe a scenario where using the wrong one causes a deadlock.