SignalSync

Description

This program demonstrates the synchronisation between several threads with signals. It uses one core and a kernel.

There are four threads:

  • Thread 0: the usual blinker, period-triggered, “heartbeat” indicator
  • Threads 1 and 2: running the same code, they simply await a signal from thread 3, print a message, and await again. That is, these two threads are not triggered by periodic timing, but the reception of the signal. Both threads await the same signal.
  • Thread 3: periodically send the awaited signal.

Since both receiving threads 1 and 2 are awaiting the same signal, they take turns receiving it. There’s a variant, commented out, which sends the signal to both during the same cycle of thread 3.

Note: since the threads share one output terminal, the printed status messages need to be below the UART’s 32 char buffer size.

Output Terminal

See Set-up, one-terminal set-up.

Build and Run

Build module SignalSync with Astrobe, and create and upload the UF2 file using abin2uf2.

Set Astrobe’s memory options as listed, and the library search path as explained.

Repository