shared-memory

Copy-on-write file mapping on windows

≡放荡痞女 提交于 2021-02-19 04:01:46
问题 I have 3 processes communicating over named pipes: server, writer, reader. The basic idea is that the writer can store huge (~GB) binary blobs on the server , and the reader(s) can retrieve it. But instead of sending data on the named pipe, memory mapping is used. The server creates an unnamed file-backed mapping with CreateFileMapping with PAGE_READWRITE protection, then duplicates the handle into the writer . After the writer has done its job, the handle is duplicated into any number of

How do you write a full struct to shared memory in python?

天涯浪子 提交于 2021-02-17 04:58:31
问题 There are plenty of examples showing how to write single variables or even individual members of a struct to shared memory, but is there a way to put the whole struct into shared memory so that you can simply manipulate the struct to update shared memory? This is an example what I'm doing so far (in my actual program - there are over 50 fields in the struct - possibly 100+ by the time I'm done). It updates shared memory with x,y,z coordinates every 0.05 seconds. While it works as it sits, it

x86 MESI invalidate cache line latency issue

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-17 02:00:32
问题 I have the following processes , I try to make ProcessB very low latency so I use tight loop all the time and isolate cpu core 2 . global var in shared memory : int bDOIT ; typedef struct XYZ_ { int field1 ; int field2 ; ..... int field20; } XYZ; XYZ glbXYZ ; static void escape(void* p) { asm volatile("" : : "g"(p) : "memory"); } ProcessA (in core 1 ) while(1){ nonblocking_recv(fd,&iret); if( errno == EAGAIN) continue ; if( iret == 1 ) bDOIT = 1 ; else bDOIT = 0 ; } // while ProcessB ( in

Linux shared memory only allow read access

杀马特。学长 韩版系。学妹 提交于 2021-02-10 13:16:07
问题 I have a parent process that allocates shared memory and writes to it. It also starts child processes that only read the shared memory. However I don't have any control over the insights of those child processes. They are written by other programmers. These child processes are not supposed to write on the shared memory. So I wondered if I can allow them read permissions, but not write access. However with shmget you can only specify general permission without being able to distinguish between

Visibility of change to shared memory from shm_open() + mmap()

血红的双手。 提交于 2021-02-08 08:38:21
问题 Let's say I am on CentOS 7 x86_64 + GCC 7. I would like to create a ringbuffer in shared memory. If I have two processes Producer and Consumer, and both share a named shared memory, which is created/accessed through shm_open() + mmap(). If Producer writes something like: struct Data { uint64_t length; char data[100]; } to the shared memory at a random time, and the Consumer is constantly polling the shared memory to read. Will I have some sort of synchronization issue that the member length

Atomic compare, Multi-Processor, C/C++ (Linux)

随声附和 提交于 2021-02-07 09:02:31
问题 I have a variable in shared memory x on a multi- processor system. void MyFunction(volatile int* x) { if (*x != 0) { // do something } } Other processes (possibly on different processors) will be writing to x using gcc built-in atomic operations such as __sync_bool_compare_and_swap etc. I think I'm running into some cache concurrency issues where sometimes it takes a bit of time before x finally gets updated with the new value. What I want is a kind of atomic_compare (without the swap), if

Linux mapping virtual memory range to existing virtual memory range?

拜拜、爱过 提交于 2021-02-06 13:47:45
问题 In Linux, is there a way (in user space) to map a virtual address range to the physical pages that back an existing virtual address range? The mmap() function only allows one to map files or "new" physical pages. I need to be able to do something like this: int* addr1 = malloc(SIZE); int* addr2 = 0x60000; // Assume nothing is allocated here fancy_map_function(addr1, addr2, SIZE); assert(*addr1 == *addr2); // Should succeed assert(addr1 != addr2); // Should succeed 回答1: I was curious so I

Linux mapping virtual memory range to existing virtual memory range?

霸气de小男生 提交于 2021-02-06 13:46:16
问题 In Linux, is there a way (in user space) to map a virtual address range to the physical pages that back an existing virtual address range? The mmap() function only allows one to map files or "new" physical pages. I need to be able to do something like this: int* addr1 = malloc(SIZE); int* addr2 = 0x60000; // Assume nothing is allocated here fancy_map_function(addr1, addr2, SIZE); assert(*addr1 == *addr2); // Should succeed assert(addr1 != addr2); // Should succeed 回答1: I was curious so I

Sharing contiguous numpy arrays between processes in python

三世轮回 提交于 2021-02-05 20:21:57
问题 While I have found numerous answers to questions similar to mine, I don't believe it has been directly addressed here--and I have several additional questions. The motivation for sharing contiguous numpy arrays is as follows: I'm using a convolutional neural network run on Caffe to perform a regression on images to a series of continuous-value labels. The images require specific preprocessing and data augmentation. The constraints of (1) the continuous nature of the labels (they're floats)

Sharing contiguous numpy arrays between processes in python

强颜欢笑 提交于 2021-02-05 20:19:14
问题 While I have found numerous answers to questions similar to mine, I don't believe it has been directly addressed here--and I have several additional questions. The motivation for sharing contiguous numpy arrays is as follows: I'm using a convolutional neural network run on Caffe to perform a regression on images to a series of continuous-value labels. The images require specific preprocessing and data augmentation. The constraints of (1) the continuous nature of the labels (they're floats)