shared-memory

Initializing an array of structs into shared memory

て烟熏妆下的殇ゞ 提交于 2019-12-08 04:16:13
问题 I'm making 4 programs that creates a POSIX shared memory object, an array of structs, that will be shared by the other 3 processes. Basically this project simulates files. Program #1 creates the object. Program #2 takes a filename and a string as arguments, then the filename and string (file contents) are saved to shared memory as a struct that is put in an available element of the array. Program #3 will list the filenames. Program #4 will search for a given file and display its contents. The

CUDA: bad performance with shared memory and no parallelism

我们两清 提交于 2019-12-07 22:43:27
I'm trying to exploit shared memory in this kernel function, but the performance are not as good as I was expecting. This function is called many times in my application (about 1000 times or more), so I was thinking to exploit shared memory to avoid the memory latency. But something is wrong apparently because my application became really slow since i'm using shared memory. This is the kernel: __global__ void AndBitwiseOperation(int* _memory_device, int b1_size, int* b1_memory, int* b2_memory){ int j = 0; // index GPU - Transaction-wise unsigned int i = blockIdx.x * blockDim.x + threadIdx.x;

Do concurrent interlocked and reads require a memory barrier or locking?

南笙酒味 提交于 2019-12-07 18:05:24
问题 This is a simple problem, but after reading Why do I need a memory barrier? I'm very confused about it. In the example below, assume different threads are repeatedly calling Increment and Counter: class Foo{ int _counter=0; public int Counter { get { return _counter; } } public void Increment() { Interlocked.Increment(ref _counter); } } Sorry if I'm misinterpreting Why do I need a memory barrier? but it seems like it's suggesting the class above might not be providing a freshness guarantee

Adding an allocator to a C++ class template for shared memory object creation

岁酱吖の 提交于 2019-12-07 16:19:33
问题 In short, my question is: If you have class, MyClass<T> , how can you change the class definition to support cases where you have MyClass<T, Alloc> , similar to how, say, STL vector provides. I need this functionality to support an allocator for shared memory. Specifically, I am trying to implement a ring buffer in shared memory. Currently it has the following ctor: template<typename ItemType> SharedMemoryBuffer<ItemType>::SharedMemoryBuffer( unsigned long capacity, std::string name ) where

Shared Memory Segment in Operating System

只谈情不闲聊 提交于 2019-12-07 12:47:58
问题 Where is shared memory belongs to ? Which means it is owned by each individual process like stack and heap. So, other program cannot able to access the stack of some other program. Or it is a common segment of memory which is used by any number of process. The below figure shows my question diagramatically. Figure 1: ----------------- ----------------- ----------------- | stack | | stack | | stack | | | | | | | | Shared m/y | --->| Shared m/y |<--- | Shared m/y | | | | | | | | | | heap | | |

How can we share the data using shared memory segment with “Object” between two managed processes?

こ雲淡風輕ζ 提交于 2019-12-07 09:08:28
How can I share the data between two managed processes using shared memory segments? I am using "object" inside C++/CLI code to share the data with some other part of memory in the other process. I am using following code segment. #define BUFFER_SIZE 32768 #pragma data_seg (".SHAREDMEMORY") bool _Locked = false; bool _Initialized = false; unsigned char[10000] data = NULL; #pragma data_seg() #pragma comment(linker,"/SECTION:.SHAREDMEMORY,RWS") but I need it to be: #pragma data_seg (".SHAREDMEMORY") bool _Locked = false; bool _Initialized = false; object^ _object = nullptr; #pragma data_seg()

Share CGAL's geometry between processes in C++

房东的猫 提交于 2019-12-07 07:13:10
问题 I'm looking for the fastest way to send CGAL's geometry between processes (C++). Lets assume, that we have 2 processes - A and B. Process A is generating geometry and process B is displaying it. I want to connect them in the fastest awailable way. The geometry is of CGALs Polyhedron type. I know I can use shared memory, but then I've got some problems: When I want to copy geometry from process A to shared memory I can use streaming Polyhedron to/from OFF format, but I’m not interested in it,

How to use shm pixmap with xcb?

不问归期 提交于 2019-12-07 06:04:36
问题 I try to learn how to use shared memory pixmaps in the xcb library. Did any of you have experience with this and want to share example codes and/or information? This would be very helpful. Thanks 回答1: After some research I found out how to use shared memory pixmaps in xcb. Here is my testcode: #include <stdlib.h> #include <stdio.h> #include <sys/ipc.h> #include <sys/shm.h> #include <xcb/xcb.h> #include <xcb/shm.h> #include <xcb/xcb_image.h> #define WID 512 #define HEI 512 int main(){ xcb

Initializing an array of structs into shared memory

天大地大妈咪最大 提交于 2019-12-07 04:52:26
I'm making 4 programs that creates a POSIX shared memory object, an array of structs, that will be shared by the other 3 processes. Basically this project simulates files. Program #1 creates the object. Program #2 takes a filename and a string as arguments, then the filename and string (file contents) are saved to shared memory as a struct that is put in an available element of the array. Program #3 will list the filenames. Program #4 will search for a given file and display its contents. The trouble I'm having is initialize an array of structs into shared memory. I keep getting the following

How to modify shared memory (shmget/shmat) in C?

天涯浪子 提交于 2019-12-07 04:41:16
问题 I have a struct: struct sdata { int x; int y; time_t time; }; I create shared memory for the struct as follows: size_t shmsize = sizeof(struct sdata); shmid = shmget(IPC_PRIVATE, shmsize, IPC_CREAT | 0666); Then I access the shared memory like this: struct sdata *data = shmat(shared.shmid, (void *) 0, 0); data->time = time(NULL); // function returns the current time My question is pretty simple. Is this the right way to access/modify shared memory? Is this the best approach? (I am using