RtkIPC

Description

The RtkIPC example demonstrates how to synchronize a Windows driver with an RTX application using the RTX RTK API. The RTK API is analogous to the existing RTX IPC calls, but can be used by Windows drivers. This example will demonstrate how to set up a Windows driver so that it can access RTX mutexes, events, semaphores, and shared memory.

We advise that you copy this sample folder to a location where you can make changes. This is necessary because users will not have write access to the the RTX install directory without explicitly elevating applications. Also, making a copy preserves the original in case subsequent changes cause problems with the sample.

Additionally, the pathname of the directory where you copy this sample should have no spaces in its name. This is a restriction imposed by how the Windows DDK is used to build the Windows driver component of this sample.

NOTE:  In addition to the RTX SDK, you must have the following items installed in order to build and execute the sample code for RtkApiTest:

  1. A supported version of Visual Studio
  2. Microsoft Platform SDK

Building RtkApiTest

  1. See the above advice that these steps should be performed in a writable copy of the RtkIPC folder rather than the original folder where RTX was installed.
  2. Build RtkIPCDrv.sys:
  3. Open a DDK WinXP X86 Command Prompt in Administrator mode, and change directory to RtkIPC\source.
  4. If you have the DDK installed, delete the "TARGET_OS" variable: type "set TARGET_OS=WXP".
  5. If you have more than one DDK installed, make sure that the BASEDIR environment variable is set to the pathname of the DDK that you intend to use for building the driver. For example:
  6. "BASEDIR=C:\WinDDK\7600.16385.0"
  7. "MSSDK=C:\Program Files\Microsoft SDKs\"
  8. Execute RtkIPCUserBuild.bat in a DDK command prompt.
  9. Verify that RtkIPCDrv.sys built without errors.
  10. Copy RtkIPCDrv.sys to %SYSTEMROOT%\System32\Drivers.
  11. Build RtkRtssApp.rtss and RtkRtssApp.exe:
  12. Open one of the provided Visual Studio solutions in the version of Visual Studio that corresponds to the name of the containing folder (e.g., the "VS2015" folder contains the solution to use with Visual Studio 2015). The solution contains two projects: one to build an real-time RTSS application and one to build a user-space Windows executable that is used to control the sample.
  13. By default, the project is configured to demonstrate synchronization using an event.
  14. To demonstrate synchronization using a mutex, modify project RtkRtssApp_VS2015 to replace Rtk_Event_test.c with Rtk_Mutex_test.c.
  15. To demonstrate shared memory usage, modify project RtkRtssApp_VS2015 to replace Rtk_Event_test.c with Rtk_Shmem_test.c.
  16. To demonstrate synchronization using a semaphore, modify project RtkRtssApp_VS2015 to replace Rtk_Event_test.c with Rtk_Sema_test.c.
  17. Select either "Debug" or "Release" from the Solution Configurations menu in the toolbar. Then build the entire solution to create the real-time application RtkRtssApp.rtss and the Windows application RtkRtssApp.exe.
  18. Verify that the two applications were built without errors.

Running RtkApiTest

  1. Copy the batch script Source\RunWinApp.bat and the binaries RtkWinApp.exe and RtkRtssApp.rtss into a common directory.
  2. Open a Command Prompt, and change directory to the directory containing the files copied in the previous step.
  3. Type "RunWinApp start". This will load the RtkIPCDrv.sys driver.
  4. Launch the Windows executable in one of the following ways:
  5. If you have configured RtkRtssApp.rtss to demonstrate shared memory usage, type "RunWinApp shmem".
  6. If you have configured RtkRtssApp.rtss to demonstrate synchronization using a mutex, type "RunWinApp mutex".
  7. If you have configured RtkRtssApp.rtss to demonstrate synchronization using an event, type "RunWinApp event".
  8. If you have configured RtkRtssApp.rtss to demonstrate synchronization using a semaphore, type "RunWinApp semaphore".
  9. Execute RtkRtssApp.rtss by double-clicking it in Windows Explorer or by entering the command "rtssrun RtkRtssApp.rtss" a Command Prompt.
  10. Depending on the type of demonstration you are running, you should see output from both the Windows driver and RtkRtssApp.rtss.
  11. After execution is complete, unload the Windows driver by typing "RunWinApp stop".

NOTE:  The last step above must be completed before the subsystem is stopped or else a Windows restart will be required before the subsystem can be started again. The driver requires the subsystem to be running in order to completely stop itself. The subsystem can not be restarted until the driver is completely unloaded.

APIs Referenced

RTK API

RtkCloseHandle

RtkCreateEvent

RtkCreateMutex

RtkCreateSharedMemory

RtkReleaseMutex

RtkReleaseSemaphore

RtkRtssAttach

RtkRtssDetach

RtkSetEvent

RtkWaitForSingleObject

See Also

Windows Driver IPC API (RTKAPI) Overview

IntervalZero.com | Support | Give Feedback