shared-memory

How to emulate shm_open on Windows?

My service needs to store a few bits of information (at minimum, at least 20 bits or so, but I can easily make use of more) such that it persists across service restarts, even if the service crashed or was otherwise terminated abnormally it does not persist across a reboot can be read and updated with very little overhead If I store ...

Why use SysV or POSIX shared memory vs mmap()?

Needing to use IPC to pass large-ish amounts of data (200kb+) from a child process to a parent on OS X 10.4 and above, I read up on shared memory on Unix, specifically System V and POSIX shared memory mechanisms. Then I realized that mmap() can be used with the MAP_ANON and MAP_SHARED flags to do a similar thing (or just with the MAP_SH...

Windows/OS X File mapping functionality;

Is it critical to map a quantity of about 10000 4-8 Bytes large files (its about "publishing" single variables into shared memory for multiprocess rendering)? How particular does OS X mmapping differ from WinXP filemapping? ...

Detecting and controlling unauthorized shared memory reads

Hi all, I was wondering - are there any known techniques to control access to a shared memory object from anywhere but an authorized program? For instance, lets say I create a shared memory segment for use in a program P, to be accessed by Q, and I make it Read-Write. I can access it using Q because I've given it (Q) the required permi...

Is it safe to serialize a raw boost::variant?

boost::variant claims that it is a value type. Does this mean that it's safe to simply write out the raw representation of a boost::variant and load it back later, as long as it only contains POD types? Assume that it will be reloaded by code compiled by the same compiler, and same version of boost, on the same architecture. Also, (prob...

Shared Memory Example for Symbian

Hi I would like to share some memory between two processes. Unfortunately I cannot find any useful examples when using google. The only thing that comes up is how P.I.P.S can be used. But I remember that it could be done in another way, similar to the one of creating of message queues. Would be great if someone could point me in the rig...

Shared Memory Semaphore

Hi, I have 10 processes running, each writing to the same file. I don't want multiple writers, so basically I am looking for a mutex/binary semaphore to protect file writes. The problem is I can't share the semaphore amongst 10 processes, so I am looking at using shared memory between 10 processes, and putting the semaphore inside share...

How do I write to shared memory in C++?

I'd like to write to shared memory and then dump the contents to a file in the win32 api. Currently I have this code: HANDLE hFile, hMapFile; LPVOID lpMapAddress; hFile = CreateFile("input.map", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); hMapFile = CreateFileMapping(hFile, N...

Writing to shared memory

How can I write from a file to shared memory using the Win32 API? I have this code: hFile = CreateFile("input.map", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); hMapFile = CreateFileMapping(hFile, NULL, PAGE_READWRITE, 0, 0, TEXT("SharedObject")); lpMapAddre...

Multi threaded FFTW 3.1.2 on a shared memory computer

I use FFTW 3.1.2 with Fortran to perform real to complex and complex to real FFTs. It works perfectly on one thread. Unfortunately I have some problems when I use the multi-threaded FFTW on a 32 CPU shared memory computer. I have two plans, one for 9 real to complex FFT and one for 9 complex to real FFT (size of each real field: 512*512...

Distributed shared memory library for C++ ?

I am writing a distributed application framework in C++. One of the requirements is the provision of distributed shared memory. Rather than write my own from scratch (and potentially re-invent the wheel), I thought I would see if there were any pre-existing Open source libraries - a quick google search did not yield anything to useful. ...

Fastest way to share a connection and data from it with multiple processes?

I have multiple app processes that each connect to servers and receive data from them. Often the servers being connected to and the data being retrieved overlaps between processes. So there is a lot of unnecessary duplication of the data across the network, more connections than should be necessary (which taxes the servers), and the data...

MPI overhead in shared memory setup.

I want parallelize a program. It's not that difficult with threads working on one big data-structure in shared memory. But I want to be able to use distribute it over cluster and I have to choose a technology to do that. MPI is one idea. The question is what overhead will have MPI (or other technology) if I skip implementation of speci...

C++ Read from shared memory

Hi, I want to read status information that an application provides via shared memory. I want to use C++ in order to read the content of that named shared memory and then call it with pinvoke from a C#-class. From the software I know that it has a certain file structure: A struct STATUS_DATA with an array of four structs of SYSTEM_CHARA...

Do atomic operations work the same across processes as they do across threads?

Obviously, atomic operations make sure that different threads don't clobber a value. But is this still true across processes, when using shared memory? Even if the processes happen to be scheduled by the OS to run on different cores? Or across different distinct CPUs? Edit: Also, if it's not safe, is it not safe even on an operating sys...

Unexplained Linux System V IPC shared memory segment marked for destruction

I have a Linux System V IPC shared memory segment that is populated by one process and read by many others. All the processes use interface to the shared memory segment in the form of a class which takes care of looking up, attaching, and detaching to the segment as part of its constructor/destructor methods. The problem here is that...

shared memory vs distributed memory and multithread vs multiprocess

I am learning parallel programming by myself. I wonder if distributed memory is always multiprocess and multithread is always shared memory? if multiprocess can be both for distributed memory and for shared memory? Thanks and regards! ...

Are Interlocked* functions useful on shared memory?

Two Windows processes have memory mapped the same shared file. If the file consists of counters, is it appropriate to use the Interlocked* functions (like InterlockedIncrement) to update those counters? Will those synchronize access across processes? Or do I need to use something heavier, like a mutex? Or perhaps the shared-memory me...

listing shared memory objects on Solaris by name

I can use ipcs(1) to list out the active shared memory objects on a Solaris 10 box, but it lists them by key. I'm opening the objects via shm_open(3), though, which takes a character string as a name to identify the object. Is there a way to list the shared memory objects by name, or to just get the key<->name mapping? I'm mostly inte...

How do I write to a different thread's stack in C/C++?

I know this is a bad idea! Certainly for safe programming the stack for a given thread should be considered private to that thread. But POSIX at least guarantees that all of a thread's memory is shared and writeable by other threads, which means the stack of one thread can (in theory) be written to by another thread. So I'm curious how o...