shared-memory

Writing to shared memory in Python is very slow

a 夏天 提交于 2019-12-02 13:31:58
问题 I use python.multiprocessing.sharedctypes.RawArray to share large numpy arrays between multiple processes. And I've noticed that when this array is large (> 1 or 2 Gb) it becomes very slow to initialize and also much slower to read/write to (and read/write time is not predictable, sometimes pretty fast, sometimes very very slow). I've made a small sample script that uses just one process, initialize a shared array and write to it several times. And measures time to do these operations. import

Using shared memory and how to correctly unallocate a space with IPC_RMID

让人想犯罪 __ 提交于 2019-12-02 10:20:23
I have 2 applications running on my linux box, a server and a client. My server and client examples I am working with is from Dave Marshalls examples . Everything works well, but when I try this in my background process and I want to extend my original segment (perhaps due to an application upgrade in the future) I either have to change my key or somehow pass the shmctl(shmid, IPC_RMID, 0) call in my app. Since my app cannot exit graciously and I cannot set this right at the beginning after allocation (since no other app will be able to use this shared mem space once it has been marked for

How to share HGLOBAL with another application?

只谈情不闲聊 提交于 2019-12-02 09:08:03
问题 I'm trying to understand something about HGLOBAL s, because I just found out that what I thought is simply wrong. In app A I GlobalAlloc() data (with GMEM_SHARE|GMEM_MOVABLE ) and place the string "Test" in it. Now, what can I give to another application to get to that data? I though (wrongfully!) that HGLOBAL s are valid in all the processes, which is obviously wrong, because HGLOBAL is a HANDLE to the global data, and not a pointer to the global data (that's where I said "OHHHH!"). So how

Setting a value in the debugger of a shared section

自作多情 提交于 2019-12-02 08:20:25
I have the following code in a DLL: #pragma data_seg("ABC") __declspec (dllexport) char abc[2000] = { 0 }; #pragma data_seg() #pragma comment(linker, "-section:ABC,rws") I have the following code in an executable: extern "C" __declspec(dllimport) char abc[]; char *abcPtr = abc; #define iVar0 (*(long *)(abcPtr)) int main() { printf("Value: %d %p\n", iVar0, &iVar0); iVar0 = 66; printf("Value: %d %p\n", iVar0, &iVar0); char buffer[256]; scanf_s("%s", buffer, 256); } When I run the first instance of the program I get: Value: 0 0FC2A000 Value: 66 0FC2A000 If I run a second instance I get the

Writing to shared memory in Python is very slow

吃可爱长大的小学妹 提交于 2019-12-02 06:55:33
I use python.multiprocessing.sharedctypes.RawArray to share large numpy arrays between multiple processes. And I've noticed that when this array is large (> 1 or 2 Gb) it becomes very slow to initialize and also much slower to read/write to (and read/write time is not predictable, sometimes pretty fast, sometimes very very slow). I've made a small sample script that uses just one process, initialize a shared array and write to it several times. And measures time to do these operations. import argparse import ctypes import multiprocessing as mp import multiprocessing.sharedctypes as mpsc import

Trouble passing _EXCEPTION_POINTERS * using FileMapping

眉间皱痕 提交于 2019-12-02 06:32:49
问题 I wanted to do a out-of-process exception handler and i had created a watch-dog process which does dedicated exception handling when child process raises exception. I had successfully invoked the watchdog process through events . The problem i am facing is while trying to pass the exception information pointers to the other process . I landed here Passing a pointer to process spawned with exec() and came to know that passing pointers in shared memory has this issue : "If you use shared memory

How to share HGLOBAL with another application?

点点圈 提交于 2019-12-02 06:07:18
I'm trying to understand something about HGLOBAL s, because I just found out that what I thought is simply wrong. In app A I GlobalAlloc() data (with GMEM_SHARE|GMEM_MOVABLE ) and place the string "Test" in it. Now, what can I give to another application to get to that data? I though (wrongfully!) that HGLOBAL s are valid in all the processes, which is obviously wrong, because HGLOBAL is a HANDLE to the global data, and not a pointer to the global data (that's where I said "OHHHH!"). So how can I pass the HGLOBAL to another application? Notice: I want to pass just a "pointer" to the data, not

How to use shared memory between kernel call of CUDA?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 04:16:02
I want to use shared memory between kernel call of one kernel. Can I use shared memory between kernel call? No, you can't. Shared memory has thread block life-cycle. A variable stored in it can be accessible by all the threads belonging to one group during one __global__ function invocation. Take a try of page-locked memory, but the speed should be much slower than graphic memory. cudaHostAlloc (void **ptr, size_t size, cudaHostAllocMapped); then send the ptr to the kernel code. Previously you could do it in a non-standard way where you would have a unique id for each shared memory block and

Trouble passing _EXCEPTION_POINTERS * using FileMapping

邮差的信 提交于 2019-12-01 23:45:29
I wanted to do a out-of-process exception handler and i had created a watch-dog process which does dedicated exception handling when child process raises exception. I had successfully invoked the watchdog process through events . The problem i am facing is while trying to pass the exception information pointers to the other process . I landed here Passing a pointer to process spawned with exec() and came to know that passing pointers in shared memory has this issue : "If you use shared memory, you can't pass the pointer. The pointer will contain the virtual address, which is different from one

A simple C++ shared memory program written on linux: segmentation fault

∥☆過路亽.° 提交于 2019-12-01 15:51:45
问题 #include <stdio.h> #include <sys/shm.h> #include <sys/stat.h> #include <string> #include <vector> #include <iostream> using namespace std; struct LOCK { string name; string type; vector <string> pids; }; int main () { int segment_id; LOCK* shared_memory; struct shmid_ds shmbuffer; int segment_size; const int shared_segment_size = 0x6400; /* Allocate a shared memory segment. */ segment_id = shmget (IPC_PRIVATE, shared_segment_size, IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR); /* Attach the