shared-memory

How to get list of open posix shared memory segments in FreeBSD

我与影子孤独终老i 提交于 2019-12-10 04:13:19
问题 In linux i can get list of opened posix shared memory segments by getting /dev/shm directory listing. How do i programmatically get list of all opened posix shared memory segments in FreeBSD? Assuming segments opened with shm_open and i don't know even a part of a name that was used as a first argument of shm_open. 回答1: You can't. See the comment in /sys/kern/uipc_shm.c: * TODO: * * (2) Need to export data to a userland tool via a sysctl. Should ipcs(1) * and ipcrm(1) be expanded or should

Shared memory matrix multiplication kernel

有些话、适合烂在心里 提交于 2019-12-09 22:38:21
问题 I am attempting to implement a shared memory based matrix multiplication kernel as outlined in the CUDA C Programming Guide. The following is the kernel: __global__ void matrixMultiplyShared(float * A, float * B, float * C, int ARows, int AColumns, int BRows, int BColumns, int CRows, int CColumns) { float * CSub = &C[CColumns * 16 * blockIdx.y + 16 * blockIdx.x]; float CValue = 0; for (int k = 0; k < (AColumns / 16); ++k) { float * ASub = &A[AColumns * 16 * blockIdx.y + 16 * k]; float * BSub

Does `postMessage` or yielding to the event loop or similar sync shared memory?

送分小仙女□ 提交于 2019-12-09 15:01:17
问题 I don't see anything in the JavaScript spec, the proposed DOM spec extensions related to SharedArrayBuffer , or the current WHAT-WG HTML spec to suggest that shared memory will be synchronized/updated across threads when one thread posts a message to another and the other processes the message. ( After the one has already sent the shared memory to the other.) However, I'm also unable to verify experimentally that it doesn't happen (in my tests, I don't see stale values). Is there some such

Do I need to use shm_unlink on a shared memory object?

馋奶兔 提交于 2019-12-09 11:19:15
问题 I've written a server (GNU C++ / Linux) which runs continuously, and occasionally executes small stand-alone programs to do work. In order to efficiently get data to the worker programs, the server creates and maps a shared memory object (code abbreviated for clarity): int fd = shm_open("/shm_file", O_CREAT | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR); ftruncate(...); data = mmap(...); // etc... launchWorker(...); // Start the worker program The worker program then opens this shared memory in a

Windows: Resize shared memory

谁都会走 提交于 2019-12-09 11:18:33
问题 When I create a shared memory segment on Windows (like CreateFileMapping(INVALID_HANDLE_VALUE, ...) ), is there any way to resize it, other than creating a bigger segment and copying the data? I've read in MSDN that file mappings have a fixed size, but is there possibly some way to make a new mapping over the same memory? Like in Linux, where you can use shm_open() and then ftruncate() and mmap() it again. 回答1: The short answer is no - you cannot resize a file mapping once it has been created

Sharing heap memory with fork()

放肆的年华 提交于 2019-12-09 10:38:11
问题 I am working on implementing a database server in C that will handle requests from multiple clients. In order to do so I am using fork() to handle connections for individual clients. The server stores data in the heap which consists of a root pointer to hash tables of dynamically allocated records. The records are structs that have pointers to various data-types. I would like for the processes to be able to share this data so that when a client makes a change to the heap the changes will be

Using Python's multiprocessing.pool.map to manipulate the same integer

烈酒焚心 提交于 2019-12-09 06:52:32
问题 Problem I'm using Python's multiprocessing module to execute functions asynchronously. What I want to do is be able to track the overall progress of my script as each process calls and executes def add_print . For instance, I would like the code below to add 1 to total and print out the value ( 1 2 3 ... 18 19 20 ) every time a process runs that function. My first attempt was to use a global variable but this didn't work. Since the function is being called asynchronously, each process reads

Condition Variable in Shared Memory - is this code POSIX-conformant?

≡放荡痞女 提交于 2019-12-09 00:55:16
问题 Does the POSIX standard allow a named shared memory block to contain a mutex and condition variable? We've been trying to use a mutex and condition variable to synchronise access to named shared memory by two processes on a LynuxWorks LynxOS-SE system (POSIX-conformant). One shared memory block is called "/sync" and contains the mutex and condition variable, the other is "/data" and contains the actual data we are syncing access to. We're seeing failures from pthread_cond_signal() if both

Robust CRITCAL_SECTION for shared memory?

痴心易碎 提交于 2019-12-08 19:55:35
问题 We have some data structures that we are sharing across processes on Windows. (Via a shared data segment in a DLL that's loaded by all these processes.) We need to synchronize some accesses and we measured that the performance hit of using a Win32 Mutex is too costly. CRITICAL_SECTION cannot be put into shared memory due to some of it's advanced features. This leaves us with the requirement of a simple locking/mutex solution based directly on the Interlocked* family of function on Win32.

C++ : When do I need a shared memory allocator for std::vector?

核能气质少年 提交于 2019-12-08 19:40:35
First_Layer I have a win32 dll written in VC++6 service pack 6. Let's call this dll as FirstLayer. I do not have access to FirstLayer's source code but I need to call it from managed code. The problem is that FirstLayer makes heavy use of std::vector and std::string as function arguments and there is no way of marshaling these types into a C# application directly. Second_Layer The solution that I can think of is to first create another win32 dll written in VC++6 service pack 6. Let's call this dll as "SecondLayer". SecondLayer acts as a wrapper for FirstLayer. This layer contains wrapper