This sample demonstrates usage of a DLL to share data across multiple executables in an application and a mutex to synchronize access across processes.

The main program is built and linked to a DLL that contains global shared data. When run, the program starts two instances of itself, each of which creates a console window (you may need to drag one of the windows to expose the other.)  The parent window prompts for a number.  When you type the number, it is stored in the global data and then the child process wakes up, takes the square root of the number, and makes that available to the parent process which is then reawakened.  Enter 0 to exit.

The data that is shared between the parent and child process is declared inside a module. The module is built into a DLL that is linked into the main application. In order for the data to be read-write shared, the following must be done:

  1. The variables must be initialized to a non-zero value so that they are placed in the .data image section
  2. The linker command line options are modified to add: /section:.data,RWS

This tells the linker to make the .data section of the DLL read-write shared.  If this isn't done, then each process will have its own copy of the data.

For more information about using DLLs, see Creating and Using DLLs in Using Intel Visual Fortran to Create and Build Windows-Based Applications

System Requirements

Minimum requirements include a PC based on an IA-32 or Intel® 64 architecture processor supporting the Intel® Streaming SIMD Extensions 2 (Intel® SSE2) instructions (Intel® Pentium® 4 processor or later, or compatible non-Intel processor), and supported versions of the Microsoft Windows* operating system, Microsoft Visual Studio*, and the Intel® Visual Fortran compiler. Refer to the Intel® Parallel Studio XE product Release Notes for details on the complete system requirements.

Build Instructions

The sample is provided as a Microsoft Visual Studio* solution and also contains a command-line build script build.bat file. The build.bat file accepts an optional command-line argument from the following list: