shared-memory

Instantiating objects in shared memory C++

 ̄綄美尐妖づ 提交于 2019-12-20 21:43:08
问题 We have a need for multiple programs to call functions in a common library. The library functions access and update a common global memory. Each program’s function calls need to see this common global memory. That is one function call needs to see the updates of any prior function call even if called from another program. For compatibility reasons we have several design constraints on how the functions exposed by the shared library must operate: Any data items (both standard data types and

Instantiating objects in shared memory C++

拜拜、爱过 提交于 2019-12-20 21:42:00
问题 We have a need for multiple programs to call functions in a common library. The library functions access and update a common global memory. Each program’s function calls need to see this common global memory. That is one function call needs to see the updates of any prior function call even if called from another program. For compatibility reasons we have several design constraints on how the functions exposed by the shared library must operate: Any data items (both standard data types and

Why is an acquire barrier needed before deleting the data in an atomically reference counted smart pointer?

时光怂恿深爱的人放手 提交于 2019-12-20 20:17:02
问题 Boost provides a sample atomically reference counted shared pointer Here is the relevant code snippet and the explanation for the various orderings used: class X { public: typedef boost::intrusive_ptr<X> pointer; X() : refcount_(0) {} private: mutable boost::atomic<int> refcount_; friend void intrusive_ptr_add_ref(const X * x) { x->refcount_.fetch_add(1, boost::memory_order_relaxed); } friend void intrusive_ptr_release(const X * x) { if (x->refcount_.fetch_sub(1, boost::memory_order_release)

Why is an acquire barrier needed before deleting the data in an atomically reference counted smart pointer?

社会主义新天地 提交于 2019-12-20 20:16:43
问题 Boost provides a sample atomically reference counted shared pointer Here is the relevant code snippet and the explanation for the various orderings used: class X { public: typedef boost::intrusive_ptr<X> pointer; X() : refcount_(0) {} private: mutable boost::atomic<int> refcount_; friend void intrusive_ptr_add_ref(const X * x) { x->refcount_.fetch_add(1, boost::memory_order_relaxed); } friend void intrusive_ptr_release(const X * x) { if (x->refcount_.fetch_sub(1, boost::memory_order_release)

What is the point of having a key_t if what will be the key to access shared memory is the return value of shmget()?

戏子无情 提交于 2019-12-20 18:25:20
问题 When using shared memory, why should we care about creating a key key_t ftok(const char *path, int id); in the following bit of code? key_t key; int shmid; key = ftok("/home/beej/somefile3", 'R'); shmid = shmget(key, 1024, 0644 | IPC_CREAT); From what I've come to understand, what is needed to access a given shared memory is the shmid , not the key. Or am I wrong? If what we need is the shmid , what is the point in not just creating a random key every time? Edit @Beej's Guide to Unix IPC one

What special powers does ashmem have?

早过忘川 提交于 2019-12-20 16:37:08
问题 Can someone explain why ashmem was created? I'm browsing through mm/ashmem.c right now. As near as I can tell, the kernel is thinking of ashmem as file-backed memory that can be mmap'd. But then, why go to the trouble of implementing ashmem? It seems like the same functionality could be achieved by mounting a RAM fs and then using filemap/mmap to share memory. I'm sure that ashmem can do more fancy stuff -- from looking at the code, it seems to have something to do with pinning/unpinning

Program to view Shared Memory in Windows?

五迷三道 提交于 2019-12-20 14:06:30
问题 I'm looking for a program to view and browse the (local) shared memory in Windows x32/x64. I know this exists because I've seen it in action before. For some reason Google and MSDN fail me on this one. 回答1: I think Accesschk can do this. From the commandline: accesschk.exe -osv > objects.txt Search for: "Type: Section" 来源: https://stackoverflow.com/questions/465378/program-to-view-shared-memory-in-windows

Parallelise python loop with numpy arrays and shared-memory

怎甘沉沦 提交于 2019-12-20 08:41:58
问题 I am aware of several questions and answers on this topic, but haven't found a satisfactory answer to this particular problem: What is the easiest way to do a simple shared-memory parallelisation of a python loop where numpy arrays are manipulated through numpy/scipy functions? I am not looking for the most efficient way, I just wanted something simple to implement that doesn't require a significant rewrite when the loop is not run in parallel. Just like OpenMP implements in lower level

using shared memory with php and c?

时光总嘲笑我的痴心妄想 提交于 2019-12-20 02:48:08
问题 Can you use shared memory to communicate between php scripts and c program in windows? The c program runs all the time and uses memory mapped files ie: handle1 = CreateFileMapping( (HANDLE)0xFFFFFFFF, NULL, PAGE_READWRITE, 0, sizeof(byte)*BUFFER_SIZE, "my_foo" ); hView = (LPINT) MapViewOfFile(handle1, FILE_MAP_ALL_ACCESS, 0, 0, 0); For the PHP scripts can I just use the below code to open the memory mapped file created by the c program? $shmkey = @shmop_open(ftok("my_foo", 'R'), "a", 0644,

Shared memory region in NDK

梦想的初衷 提交于 2019-12-19 10:47:22
问题 I want to have a shared memory block (an ashmem region) that's mapped and accessed from native code. I also want this block to be used by several applications. I also want it to work on SDK level 7 (Android 2.1) There are two routes. I can create an ashmem region in native code; but then the question is - how do I pass an integer file descriptor to another process? You can marshal FileDescriptor objects via a Parcel , but there's no way to construct one around a raw FD. There's also