Shutdown

This sample demonstrates how to register a shutdown handler in the wRTOS Subsystem (RTSS). While running, it generates a continuous audio tone using a periodic timer. When the system shuts down, the handler is invoked, prints a notification message, pauses for a configurable number of seconds (default 10), stops the tone, and then allows the system shutdown sequence to continue. The sample runs indefinitely until a shutdown event occurs.

Source Files

File Description
Shutdown.c The project source file. This project sets up a continuous periodic timer that drives the speaker. When the shutdown occurs (either a normal Windows shutdown or a Blue Screen stop), the shutdown handler is called and prints a message, waits ten seconds, and then stops the timer and returns, allowing Windows to complete the shutdown.

Building the Sample

Build the sample using either RTSS configuration: RTSSDebug or RTSSRelease ( .rtss executable binary file).

Running the Sample

  1. Run the sample in the real-time environment.
  2. Test the two shutdown behavior types by forcing Windows to shut down via the following methods:

Note: On Windows 10, the thread will continue running, but no output will appear on the screen.

Usage

rtssrun Shutdown.rtss bSound ShutDownHoldtime

Options

bSound (optional)

Enable (1) or disable (0) the audio tone. Default is 1 (enabled).

ShutdownHoldTime (optional)

The time in seconds the handler sleeps during shutdown. The default is 10 seconds.

Example

This command runs with sound enabled and a 15-second shutdown pause:

shutdown.exe 1 15

Expected Results

Remarks

APIs Referenced

RTAPI

Windows-Supported