So, when do we need to use mutexes and semaphores? Any time there is a shared resource between multiple tasks, either a mutex or a semaphore should be used. Standard binary semaphores can be used for resource protection, so in some special cases (such as semaphores being accessed from ISRs), semaphores can be desirable. However, you must understand how waiting on the semaphore will affect the system.
We saw a mutex in action in the previous example, but what would it look like if there was no mutex and we only wanted one of the blue or green LEDs to be on at a time?