Any idea why the context switch is slow?
Typical RTOS times are faster. For ChibiOS/RT giving a semaphore plus a context switch to the task that takes the semaphore is:
Uno: 15 us
Teensy 3.0: 3 us
Due: 2 us
Task context switch time are less, 11.25 us for 16 MHz AVR and 1.02 us for 72 MHz ARM CM3. ChibiOS free embedded RTOS - This topic does not exist yet
Clearly this is not a problem for a cooperative scheduler.