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)

/media/uploads/stefanwaldschmidt/2019-05-10-semaphore_ping_pong.gif

mbed-os.lib

Committer:
stefanwaldschmidt
Date:
2019-05-11
Revision:
0:ea879e5f3ce5

File content as of revision 0:ea879e5f3ce5:

https://github.com/ARMmbed/mbed-os.git/#0f959dbe4749c20416236e4fe1dac5692cbe18ab