Explain the difference between a semaphore and a mutex in a real-time context for FreeRTOS-based firmware.