shared-memory

Low-level shared memory on iOS

时光总嘲笑我的痴心妄想 提交于 2019-12-19 10:21:57
问题 I'm trying to construct a block of shared memory on iOS. It compiles and links, but shmget() throws a SIGSYS signal on the most innocent parameters: NSString *p = [[NSBundle mainBundle] pathForResource:@"crash" ofType: nil]; key_t tok = ftok([p UTF8String], 918273); int mid = shmget(tok, 4096, IPC_CREAT|S_IRUSR|S_IWUSR); tok is a large positive integer, not -1. Size - tried 1024, same effect. Is SysV shared memory even supported on iOS? The headers and the libraries are present, or compiler

Map in Shared memory

こ雲淡風輕ζ 提交于 2019-12-19 06:25:40
问题 I am trying to create an unordered_map in shared memory. I am using allocator to server the purpose. The code void *addr; void *pool; int shmid; template<class T> class MyPoolAlloc { private: public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef T* pointer; typedef const T* const_pointer; typedef T& reference; typedef const T& const_reference; typedef T value_type; template<class X> struct rebind { typedef MyPoolAlloc<X> other; }; MyPoolAlloc() throw() { } MyPoolAlloc

ftruncate not working on POSIX shared memory in Mac OS X

不羁的心 提交于 2019-12-19 02:07:34
问题 I have written a code on Mac OS X to use POSIX shared memory as shown below: #include <sys/mman.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <sys/types.h> int main() { int fileHandle = shm_open("TW_ShMem1",O_CREAT|O_RDWR, 0666); if(fileHandle==-1) { //error. } else { //Here, it is failing on Mac OS X if(-1==ftruncate(fileHandle, 8192)) { shm_unlink("TW_ShMem1"); fileHandle = -1; } else { return 0; } } return 1; } ftruncate on Linux is working without any problem.

C static variables and linux fork

…衆ロ難τιáo~ 提交于 2019-12-19 00:42:38
问题 Hi I created a server program that forks a new process after its accepts a socket connection. There are several statically allocated global variables defined in the program. My question is are these static buffers allocated twice after the fork? Or does the fork only duplicate address space on the heap and the call stack? 回答1: The entire address space is duplicated, including all global variables and the program text. 回答2: The whole address space is "duplicated" during fork(2) . It's often

How to use coalesced memory access

六月ゝ 毕业季﹏ 提交于 2019-12-19 00:40:09
问题 I have 'N' threads to perform simultaneously on device which they need M*N float from the global memory. What is the correct way to access the global memory coalesced? In this matter, how the shared memory can help? 回答1: Usually, a good coalesced access can be achieved when the neighbouring threads access neighbouring cells in memory. So, if tid holds the index of your thread, then accessing: arr[tid] --- gives perfect coalescence arr[tid+5] --- is almost perfect, probably misaligned arr[tid

System V shared memory in Python?

无人久伴 提交于 2019-12-18 11:54:06
问题 How can I make use of the shmat() , shmdt() , shmctl() , shmget() calls from Python? Are they hidden somewhere in the standard library? Update0 I'm after System V bindings that can be found in the Ubuntu repositories, or Python standard libraries (now or in future releases). 回答1: Google finds sysv_ipc. 回答2: If you don't want to use any non-standard Python libraries, perhaps you could wrap the functions you need yourself using ctypes? 回答3: This page offers a feature matrix to help you choose

Trouble with boost::lockfree::queue in shared memory (boost 1.53, gcc 4.7.2 / clang 3.0-6ubuntu3)

柔情痞子 提交于 2019-12-18 05:48:06
问题 I have a problem with placing boost::lockfree::queue<<T, fixed_sized<false>, ..> in shared memory. I need it because I have to be able to insert more than 65535 messages into the queue, and fixed_sized queue is limited with 65535. The following code works properly (but capacity<...> option implies fixed_sized<true> ): typedef boost::interprocess::allocator< MessageT, boost::interprocess::managed_shared_memory::segment_manager> ShmemAllocator; typedef boost::lockfree::queue< MessageT, boost:

Java and C++ Shared Memory

情到浓时终转凉″ 提交于 2019-12-18 04:44:40
问题 I have a C++ piece of code that creates shared memory. Is it possible to write Java Code which can read the memory created by the C++ code unless using JNI. By the way I am using Windows OS. 回答1: See MappedByteBuffer. It's the standard Java class to read & write shared memory. I use it a lot. Yes, you can use this to communicate with any program written in any language which uses shared memory, and it's all very standard Java, no JNI. 回答2: Yes, you can use code project :code project 来源: https

R and shared memory for parallel::mclapply

自古美人都是妖i 提交于 2019-12-18 04:16:09
问题 I am trying to take advantage of a quad-core machine by parallelizing a costly operation that is performed on a list of about 1000 items. I am using R's parallel::mclapply function currently: res = rbind.fill(parallel::mclapply(lst, fun, mc.cores=3, mc.preschedule=T)) Which works. Problem is, any additional subprocess that is spawned has to allocate a large chunk of memory: Ideally, I would like each core to access shared memory from the parent R process, so that as I increase the number of

Use shared GPU memory with TensorFlow?

怎甘沉沦 提交于 2019-12-18 03:16:25
问题 So I installed the GPU version of TensorFlow on a Windows 10 machine with a GeForce GTX 980 graphics card on it. Admittedly, I know very little about graphics cards, but according to dxdiag it does have: 4060MB of dedicated memory (VRAM) and; 8163MB of shared memory for a total of about 12224MB . What I noticed, though, is that this "shared" memory seems to be pretty much useless. When I start training a model, the VRAM will fill up and if the memory requirement exceeds these 4GB , TensorFlow