Help wanted: shared memory between a Fortran program and processes created with spawnl()

  • Thread starter Thread starter DonDilworth
  • Start date Start date
D

DonDilworth

Guest
I have studied the documentation about file and memory mapping via CreateFileMappingA() and how to use it. The examples show how to share a short character string between two processes. That's not what I'm after.

I have an array of double precision numbers (6015401 of them!) that I want spawned processes to be able to write to. Can anyone give me an example of how to do this? Here's my code so far. It won't compile.

void mymap( double& DERIV ) // create mapping of data for other cores
{

HANDLE hMapFile;
PVOID pBuff;
int size = 6015401;

TCHAR mapfilename[]= TEXT("SYNOPSYS_MMAP_DATA");

hMapFile = CreateFileMapping(
INVALID_HANDLE_VALUE, // is memory, not a disk file
NULL, // default security
PAGE_READWRITE, // access
0,
size,
mapfilename);

if ( hMapFile == NULL )
{
_tprintf(TEXT("Could not create file mapping object (%d).n"),GetLastError());
return;
}

pBuff = ( PVOID ) MapViewOfFile( hMapFile,
FILE_MAP_ALL_ACCESS,
0,
0,
size );

if ( pBuff == NULL )
{
_tprintf(TEXT("Could not map fiew of file (%d).n"),GetLastError());
CloseHandle( hMapFile );
return;
}

CopyMemory( pBuff, DERIV, size );

}

How can I arrange things so the other processes can access that array of numbers?

Continue reading...
 

Similar threads

Back
Top