shared-memory

**Non-Boost** STL allocator for shared memory

我的未来我决定 提交于 2019-12-04 18:09:19
问题 Due to policy where I work, I am unable to use a version of Boost newer than 1.33.1 and unable to use a version of GCC newer than 4.1.2. Yes, it's garbage, but there is nothing I can do about it. Boost 1.33.1 does not contain the interprocess library. That said, one of my projects requires placing an std::map (or more likely an std::unordered_map ) in to shared memory. It is only written/modified ONE TIME when the process loads by a single process (the "server") and read by numerous other

What happens when two processes are trying to access a critical section with semaphore = 0?

与世无争的帅哥 提交于 2019-12-04 17:24:16
In my code I do the following initialization : struct PipeShm myPipe = { .init = 0 , .flag = FALSE , .mutex = NULL , .ptr1 = NULL , .ptr2 = NULL , .status1 = -10 , .status2 = -10 , .semaphoreFlag = FALSE }; int initPipe() { if (!myPipe.init) { myPipe.mutex = mmap (NULL, sizeof *myPipe.mutex, PROT_READ | PROT_WRITE,MAP_SHARED | MAP_ANONYMOUS, -1, 0); if (!sem_init (myPipe.mutex, 1, 0)) // semaphore is initialized to 0 { myPipe.init = TRUE; } else perror ("initPipe"); } return 1; // always successful } I can have multiple processes that can be invoked from main() (note the fork ) . Thanks AFAICS

Allocating a user defined struct in shared memory with boost::interprocess

泄露秘密 提交于 2019-12-04 16:46:34
I am trying to use boost::interprocess to allocate a very simple data structure in shared memory but I cannot quite figure out how to use the boost interprocess allocators to perform the memory allocations/deallocations within the shared memory segment which I allocate as follows using namespace boost::interprocess; shared_memory_object::remove("MySharedMem"); mSharedMemory = std::make_unique<managed_shared_memory>( open_or_create, "MySharedMem", 65536); I previously asked a similar question but unfortunately I never got any answers. MyStruct below is essentially an array with a length field

How to Change the Size of /dev/shm in App Engine Flexible

流过昼夜 提交于 2019-12-04 14:57:16
How do you change the size of the shared memory folder /dev/shm in an App Engine Flexible app? By default it is set to 64M, too low to run many apps (e.g., chrome). I don't see any way to change it. There are ways to change it if you have access to the docker run command , but we don't have such access when launching app engine flexible apps. A: No. Unfortunately this isn't possible (yet?) with appengine. More than a few people have run into this issue. For some reason, the container default for /dev/shm is crazy small. ...but there are other options If the process you want to run has the

Memory Mapped Files, Managed Mapped File and Offset Pointer

落爺英雄遲暮 提交于 2019-12-04 13:49:06
I'm a little bit confused about the terminology of Boost Library (for windows). What I'm trying to do is simply; create a file on disk (a big file >50 GB) do some mapping for write and read operations seperately. For example first map 1 gb portion for writing & after that flush it to the hard drive take a new portion and so on, while the reader applications maps different parts of the file and do the reading stuff without changing anything (no edit). I'm reading the documentation of boost (1.47.0 version since we allowed to use this one) and I don't understand exactly when to use Memory Mapped

Communication of parallel processes: what are my options?

依然范特西╮ 提交于 2019-12-04 12:44:23
问题 I'm trying to dig a bit deeper into parallelziation of R routines. What are my options with respect to the communication of a bunch of "worker" processes regarding the communication between the respective workers ? the communication of the workers with the " master " process? AFAIU, there's no such thing as a " shared environment/shared memory " that both the master as well as all worker processes have access to, right? The best idea I came up with so far is to base the communication on

Can python processes share live objects?

非 Y 不嫁゛ 提交于 2019-12-04 11:33:29
问题 I have a multi-process python application (processes are spawned by uwsgi) that needs to store variables in RAM, then read and update those variables from several different processes. I know there are a lot caching options available, but all the ones I've found can only store strings. Is it possible for different python processes to access the same virtual memory, and thus share data without ever converting it or even copying it? 回答1: Besides POSH, Python Shared Objects, which at least does a

Linux Shared Memory Synchronization

末鹿安然 提交于 2019-12-04 11:20:43
问题 I have implemented two applications that share data using the POSIX shared memory API (i.e. shm_open ). One process updates data stored in the shared memory segment and another process reads it. I want to synchronize the access to the shared memory region using some sort of mutex or semaphore. What is the most efficient way of do this? Some mechanisms I am considering are A POSIX mutex stored in the shared memory segment (Setting the PTHREAD_PROCESS_SHARED attribute would be required)

How are windows DLL actually shared?

元气小坏坏 提交于 2019-12-04 08:52:37
By examing several DLLs I have in my windows machine (for instance KERNEL32.DLL) I've notice that none of their sections, not even the read only data section have the IMAGE_SCN_MEM_SHARED flag set. DLLs are mapped from the .dll file so only when you read a page of the file it is copied to physical memory but still, if the same page of let's say kernel32.dll is accessed by both process A and process B then the page will exist twice in physical memory. I am asking for the veracity of this last statement. If the .text or the .rodata segment where shared they would get copied to physical memory

Shared memory file in PHP

旧城冷巷雨未停 提交于 2019-12-04 08:35:43
问题 I use openssl_pkcs7_sign and openssl_pkcs7_encrypt to create encrypted data. The functions only accept file names. I would like to store the temporary files in shared memory to improve performance. I understand in Linux I can file_put_contents('/dev/shm/xxx', data) , but it is not possible for Windows. Is there portable way in PHP to do this? Would shmop_ function help here? Thanks. PS: Or is there way to make these functions accept data strings? PS2: Please do not suggest invoking /usr/bin