FastSemaphore Sample

This sample demonstrates the usage and abilities of the FastSemaphore functions. It runs a series of tests cycling through different semaphore usage modes and creates multiple worker threads bound to real-time processors (except the main thread's processor). Each worker thread runs a test loop that either acquires or releases semaphores, or waits for release signals, depending on the test type. During the tests, the sample monitors semaphore acquisition accuracy and timing differences between thread wakeups.

This sample:

Note: This sample requires at least two RTSS cores. Make sure at least two system cores are assigned to RTSS in your core configuration.

Source Files

File Description
FastSemaphore.h Header file.
FastSemaphore.c Source file.
FastSemaphore_VS<Visual Studio version>.vcxproj Project file for supported versions of Visual Studio.
FastSemaphore_VS<Visual Studio version>.sln Solution file for supported versions of Visual Studio.

Building the Sample

Build the sample using either of the two available RTSS configurations: RTSSDebug or RTSSRelease (Name: FastSemaphore.rtss)

Running the Sample

Run the sample using RtssRun:

Rtssrun <build-path>\FastSemaphore.rtss

Expected Results

The console prints start and end details for each test, including the number of worker threads involved.

It reports any errors encountered during semaphore operations and outputs validation results, including:

When successful, all tests pass, count1 and count2 remain equal, and the max time difference is between 3 microseconds.

Unexpected Results

There are not enough cores assigned to RTSS in the core configuration to run all threads.

APIs Referenced

RTAPI

Windows-Supported