shared-memory

How do I synchronize access to shared memory in LynxOS/POSIX?

I am implementing two processes on a LynxOS SE (POSIX conformant) system that will communicate via shared memory. One process will act as a "producer" and the other a "consumer". In a multi-threaded system my approach to this would be to use a mutex and condvar (condition variable) pair, with the consumer waiting on the condvar (with pt...

Using CreateFileMapping between two programs - C

Hello, I have two window form applications written in C, one holds a struct consisting of two integers, another will receive it using the CreateFileMapping. Although not directly related I want to have three events in place so each of the processes can "speak" to each other, one saying that the first program has something to pass to th...

Boost::Interprocess Container Container Resizing No Default Constructor

Hi, After combing through the Boost::Interprocess documentation and Google searches, I think I've found the reason/workaround to my issue. Everything I've found, as I understand it, seems to be hinting at this, but doesn't come out and say "do this because...". But if anyone can verify this I would appreciate it. I'm writing a series...

C - fork() and sharing memory

I need my parent and child process to both be able to read and write the same variable (of type int) so it is "global" between the two processes. I'm assuming this would use some sort of cross-process communication and have one variable on one process being updated. I did a quick google and IPC and various techniques come up but I don'...

Resize shared memory

Hi, I'd like to know if there is any way to resize a variable of QSharedMemory (in Qt) once it has been allocated. Thanks ...

How can I share dynamic data array between Applications?

Hi, I use CreateFileMapping, but this method was not useful,because only static structure can be shared by this method. for example this method is good for following structure: struct MySharedData { unsigned char Flag; int Buff[10]; }; but it's not good for : struct MySharedData { unsigned char Flag; int *Buff; }; woul...

Shared Memory and Process Sempahores (IPC)

This is an extract from Advanced Liniux Programming: Semaphores continue to exist even after all processes using them have terminated. The last process to use a semaphore set must explicitly remove it to ensure that the operating system does not run out of semaphores.To do so, invoke semctl with the semaphore identifier, the number of...

Java Thread - Memory consistency errors

I was reading a Sun's tutorial on Concurrency. But I couldn't understand exactly what memory consistency errors are? I googled about that but didn't find any helpful tutorial or article about that. I know that this question is a subjective one, so you can provide me links to articles on the above topic. It would be great if you explai...

Optimizing a shared buffer in a producer/consumer multithreaded environment

I have some project where I have a single producer thread which writes events into a buffer, and an additional single consumer thread which takes events from the buffer. My goal is to optimize this thing for a single dual-core machine to achieve maximum throughput. Currently, I am using some simple lock-free ring buffer (lock-free is po...

.net 4.0 creating a MemoryMappedFile with global context throws exception

Hi all, I want to create a global MemoryMappedFile in C# 4.0 using following call: string MemoryMappedFileName = "Global\\20E9C857-C944-4C35-B937-A5941034D073"; ioBuffer = MemoryMappedFile.CreateNew(MemoryMappedFileName, totalIoBufferSize); This always throws following exception "System.UnauthorizedAccessException: Access to the path...

Condition Variable in Shared Memory - is this code POSIX-conformant?

Does the POSIX standard allow a named shared memory block to contain a mutex and condition variable? We've been trying to use a mutex and condition variable to synchronise access to named shared memory by two processes on a LynuxWorks LynxOS-SE system (POSIX-conformant). One shared memory block is called "/sync" and contains the mutex ...

Shared mmap co-ordination using fcntl locks?

When using mmap() for shared memory (from Linux, or other UNIX-like systems) is it possible (and portable) to use fcntl() (or flock() or lockf() functions) to co-ordinate access to the mapping? Responses to this SO question seems to suggest that it should work. The idea I have in mind would be to have the shared memory structured with...

Basic shared memory program in C

Hi, I want to make a basic chat application in C using Shared memory. I am working in Linux. The application consist in writing the client and the server can read, and if the server write the client can read the message. I tried to do this, but I can't achieve the communication between client and server. The code is the following: Ser...

Linux Shared Memory

The function which creates shared memory in *inux programming takes a key as one of its parameters.. What is the meaning of this key? And How can I use it? Edit: Not shared memory id ...

IPC speed and compare

I am trying to implement a real-time application which involves IPC across different modules. The modules are doing some data intensive processing. I am using message queue as the backbone(Activemq) for IPC in the prototype, which is easy(considering I am a totally IPC newbie), but it's very very slow. Here is my situation: I have i...

Does OpenCL allow concurrent writes to same memory address?

Is two (or more) different threads allowed to write to the same memory location in global space in OpenCL? The write is always changing a uchar from 0 to 1 so the outcome should be predictable, but I'm getting erratic results in my program, so I'm wondering if the reason can be that some of the writes fail. Could it help to declare the ...

Help with POCO library (Shared memory)

I was advised to use the POCO library for inter-process communication (IPC). Looks like a powerful library and there is some documentation in the code, but I would prefer a working example , since I am not very familiar with the IPC stuff. I 've been searching for some time now and I'm out of luck. If anyone has used POCO Shared Memor...

Does a CPU assigns a value atomically to memory?

Hi! A quick question I've been wondering about for some time; Does the CPU assign values atomically, or, is it bit by bit (say for example a 32bit integer). If it's bit by bit, could another thread accessing this exact location get a "part" of the to-be-assigned value? Think of this: I have two threads and one shared "unsigned int" var...

Can processor cores thrash each other's caches?

If more than one core on a processor is accessing the same memory address, will they thrash each other's caches or will some snooping protocol allow each to keep the data in L1-cache? I am interested in a general answer as well as answers for specific processors. How many layers of cache are invalidated? Will accessing another address w...

Thread stuck in mutex wait while searching in Boost Interprocess managed_shared_memory

Hi All, We are using boost::interprocess::managed_shared_memory. Recently while testing we found that after process crash threads searching in shared memory got stuck in manage_shared_memory APIs. My initial observation is that m_header recursive lock which is member of segment_manager was in locked state while process crashed and res...