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
- Run the sample in the real-time environment.
- Test the two shutdown behavior types by forcing Windows to shut down via the following methods:
- Use the Windows utility NotMyFault, available from Microsoft at https://docs.microsoft.com/en-us/sysinternals/downloads/notmyfault, to generate a Windows Blue Screen.
- Shut down the machine through the Start menu.
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
- The sample prints startup messages explaining its function.
- The handler sleeps for the specified time before shutting down.
- If bSound is enabled (1), a continuous tone plays while the sample runs and stops cleanly after shutdown handling.
Remarks
- See also Shutdown Handling.
- The shutdown handler’s sleep allows testing of cleanup during shutdown delays.
APIs Referenced
|
RTAPI |
Windows-Supported |
|---|---|