Test the thread switching time by implementing semaphore ping-pong between two threads.
Measure thread switching time by implementing semaphore ping-pong between two threads
This mbed program starts two threads with realtime-priority. Each of them is waiting for the other to give its semaphore and gives the other thread's semaphore as a reaction. Once started, this algorithm results in fast thread switches, enforced by the semaphores.
To allow measurement, one thread sets a GPIO output, while to other one clears it.
Measurements are performed on a NUCLEO-F767ZI board https://os.mbed.com/platforms/ST-Nucleo-F767ZI/.
mbed-os-5.12.3
Measured gpio_out output frequency, whitch contains actually two thread switches:
- 6.5 - 7.0 usec (154 kHz - 143 kHz)