shared-memory

pthread Thread objects reset their state

自闭症网瘾萝莉.ら 提交于 2019-11-27 06:05:26
问题 Working recently with the extension pthreads, i discovered an anomaly. I have a simple object with an internal state: class Sum { private $value = 0; public function add($inc) { $this->value += $inc; } public function getValue() { return $this->value; } } Now i created a Thread class that does something with this object: class MyThread extends Thread { private $sum; public function __construct(Sum $sum) { $this->sum = $sum; } public function run(){ for ($i=0; $i < 10; $i++) { $this->sum->add

Giving access to shared memory after child processes have already started

99封情书 提交于 2019-11-27 05:45:31
问题 How do I give child processes access to data in shared memory if the data is only available after the child processes have been spawned (using multiprocessing.Process)? I am aware of multiprocessing.sharedctypes.RawArray, but I can't figure out how to give my child processes access to a RawArray that is created after the processes have already started. The data is generated by the parent process, and the amount of data is not known in advance. If not for the GIL I'd be using threading instead

How can I store data in RAM memory using PHP?

吃可爱长大的小学妹 提交于 2019-11-27 02:49:56
问题 Is there a way to store small data in RAM memory using PHP so that I can have access to the data between different session instead of regenerating it. Something similar to memcached (I don't have access to memcahced). My current solution is just to save the data in file. 回答1: APC? It works differents from memcached; in memcached you can access the data from various languages (c, python, etc..) while APC works only for PHP. EDIT are you sure that APC is installed correctly? Did you add

Sharing data array between two applications in Delphi

馋奶兔 提交于 2019-11-27 02:49:25
问题 I want to share array data between two applications. In my mind, first program create the array and the second program can read the array from already allocated memory area. The array is not a dynamic array. I found a way to share pointer using OpenFileMapping and MapViewOfFile . I have no luck to implement array sharing and I think i don't want to use IPC method yet. Is it possible to plan a scheme like this (sharing array)? My purpose is to minimize memory usage and reading data quickly.

How to use Shared Memory (IPC) in Android

痴心易碎 提交于 2019-11-27 02:26:01
问题 I've already written a simple Shared Memory C program in Linux. How can I use Shared Memory (or should I call it "ashmem?") in Android? I hope you can give me a step-by-step guide. 回答1: Here is what worked for me: 1) Open a MemoryFile object: mFile; 2) create a service to map it to ashem using mmap; 3) Return the native file descriptor (fd) to client that binds to your service using ParcelFileDescriptor pfd; 4) Create JNI for the client that takes the fd and map to ashes using mmap; 5) Create

Good alternative to shared memory IPC for Java/C++ apps on Linux

淺唱寂寞╮ 提交于 2019-11-27 02:02:35
问题 I'm currently using shared memory for IPC between Java and C++ apps, but looking for a more convenient alternative. Can someone advise a better method with same performance and speed? Thanks! 回答1: It depends on how you plan to have your apps interact. In the POSIX environment, you have pipes, shared memory, sockets, semaphores and message queues. See this question: Comparing unix linux IPC for more information. What is the interaction model for your processes (i.e. client/server, producer

What does the shmop PHP extension do?

对着背影说爱祢 提交于 2019-11-27 01:38:49
问题 http://www.php.net/manual/en/intro.shmop.php Shmop is an easy to use set of functions that allows PHP to read, write, create and delete Unix shared memory segments. I don't understand, what exactly is the purpose of this extension? What is it used for? 回答1: Shared memory allows multiple processes to access the same data in memory. You can use it to share data among running PHP scripts. $shm = shmop_open(0xF00, "c", 0644, 4); $count = unpack('L', shmop_read($shm, 0, 4)); $count = reset($count)

Shared memory between C++ and Java processes

拜拜、爱过 提交于 2019-11-27 01:21:55
问题 My aim is to pass data from a C++ process to a Java process and then to receive a result back. I have achieved this via a named pipe but I would prefer to share the data rather than passing or copying it, assuming the access would be faster. Initially, I thought of creating a shared segment in C++ that I could write to and read with Java, but I'm not sure if this is possible via JNI, let alone safe. I believe it's possible in Java to allocate the memory using ByteBuffer.allocateDirect and

Is there a way in PHP to use persistent data as in Java EE? (sharing objects between PHP threads) without session nor cache/DB

隐身守侯 提交于 2019-11-26 23:28:46
问题 Is there a way in PHP to use "out of session" variables, which would not be loaded/unloaded at every connexion, like in a Java server ? Please excuse me for the lack of accuracy, I don't figure out how to write it in a proper way. The main idea would be to have something like this : <?php ... // $variablesAlreadyLoaded is kind of "static" and shared between all PHP threads // No need to initialize/load/instantiate it. $myVar = $variablesAlreadyLoaded['aConstantValueForEveryone']; ... ?> I

How to perform reduction on a huge 2D matrix along the row direction using cuda? (max value and max value's index for each row)

两盒软妹~` 提交于 2019-11-26 23:26:39
问题 I'm trying to implement a reduction along the row direction of a 2D matrix. I'm starting from a code I found on stackoverflow (thanks a lot Robert!) thrust::max_element slow in comparison cublasIsamax - More efficient implementation? The above link shows a custom kernel that performs reduction on a single row. It divides the input row into many rows and each row has 1024 threads. Works very well. For the 2D case, everything's the same except that now there's a y grid dimension. So each block