shared-memory

Deleting shared memory with ipcrm in Linux

ぃ、小莉子 提交于 2019-12-01 14:58:42
I am working with a shared memory application, and to delete the segments I use the following command: ipcrm -M 0x0000162e (this is the key) But I do not know if I'm doing the right things, because when I run ipcs I see the same segment but with the key 0x0000000. So is the memory segment really deleted? When I run my application several times I see different memory segments with the key 0x000000, like this: key shmid owner perms bytes nattch status 0x00000000 65538 me 666 27 2 dest 0x00000000 98307 me 666 5 2 dest 0x00000000 131076 me 666 5 1 dest 0x00000000 163845 me 666 5 0 What is actually

Unix Programming Shared Memory strange results

痞子三分冷 提交于 2019-12-01 14:34:02
I have been working on semaphores and shared memory for a week now, and have some difficulties yet,so i tried to make this program which the children are supposed to write to a memory shared multidimensional integer array and the father is suppose to read that array from the memory that is shared. #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/ipc.h> #include <sys/shm.h> #include <stdio.h> #include <sys/fcntl.h> #include <semaphore.h> #include <sys/wait.h> #define MAXCHILDS 1 #define MAX_SIZE 10 #define MAX_WRITES 100 typedef struct{ int m[MAX_SIZE][MAX_SIZE]; }matrix

How to get Shared Object in Shared Memory

不想你离开。 提交于 2019-12-01 13:36:57
Our app depends on an external, 3rd party-supplied configuration (including custom driving/decision making functions) loadable as .so file. Independently, it cooperates with external CGI modules using a chunk of shared memory, where almost all of its volatile state is kept, so that the external modules can read it and modify it where applicable. The problem is the CGI modules require a lot of the permanent config data from the .so as well, and the main app performs a whole lot of entirely unnecessary copying between the two memory areas to make the data available. The idea is to make the whole

How do you make a worker process block while waiting for Value or Array from multiprocessing?

北慕城南 提交于 2019-12-01 13:10:42
问题 This document shows an example to share state between processes using Value and Array from multiprocessing library: from multiprocessing import Process, Value, Array def f(n, a): n.value = 3.1415927 for i in range(len(a)): a[i] = -a[i] if __name__ == '__main__': num = Value('d', 0.0) arr = Array('i', range(10)) p = Process(target=f, args=(num, arr)) p.start() p.join() print(num.value) print(arr[:]) It will print 3.1415927 [0, -1, -2, -3, -4, -5, -6, -7, -8, -9] My questions are How to you

Shared memory region in NDK

喜欢而已 提交于 2019-12-01 12:55:24
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 ParcelFileDescriptor which supports constructing around and retrieving integer FD's, but the relevant methods

Unix Programming Shared Memory strange results

南楼画角 提交于 2019-12-01 12:43:10
问题 I have been working on semaphores and shared memory for a week now, and have some difficulties yet,so i tried to make this program which the children are supposed to write to a memory shared multidimensional integer array and the father is suppose to read that array from the memory that is shared. #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/ipc.h> #include <sys/shm.h> #include <stdio.h> #include <sys/fcntl.h> #include <semaphore.h> #include <sys/wait.h> #define

MPI-3 Shared Memory for Array Struct

余生颓废 提交于 2019-12-01 12:33:52
I have a simple C++ struct that basically wraps a standard C array: struct MyArray { T* data; int length; // ... } where T is a numeric type like float or double . length is the number of elements in the array. Typically my arrays are very large (tens of thousands up to tens of millions of elements). I have an MPI program where I would like to expose two instances of MyArray , say a_old and a_new , as shared memory objects via MPI 3 shared memory. The context is that each MPI rank reads from a_old . Then, each MPI rank writes to certain indices of a_new (each rank only writes to its own set of

How to use shared memory in android native code?

百般思念 提交于 2019-12-01 11:28:53
I am porting an existing linux application to android. The application is using shared memory API's like shm_open() etc. Checking bionic in android source , I see that these API's are not supported. Hence I get a linking error during build. external/l2/avbtp.c:138: error: undefined reference to 'shm_open' external/l2/avbtp.c:151: error: undefined reference to 'shm_unlink' external/l2/avbtp.c:186: error: undefined reference to 'shm_unlink' How to resolve this correctly? Android intentionally doesn't provide SysV IPC . Try to avoid using of shared memory or, if you really want, look for examples

MPI-3 Shared Memory for Array Struct

假如想象 提交于 2019-12-01 10:49:26
问题 I have a simple C++ struct that basically wraps a standard C array: struct MyArray { T* data; int length; // ... } where T is a numeric type like float or double . length is the number of elements in the array. Typically my arrays are very large (tens of thousands up to tens of millions of elements). I have an MPI program where I would like to expose two instances of MyArray , say a_old and a_new , as shared memory objects via MPI 3 shared memory. The context is that each MPI rank reads from

How to get Shared Object in Shared Memory

流过昼夜 提交于 2019-12-01 10:33:49
问题 Our app depends on an external, 3rd party-supplied configuration (including custom driving/decision making functions) loadable as .so file. Independently, it cooperates with external CGI modules using a chunk of shared memory, where almost all of its volatile state is kept, so that the external modules can read it and modify it where applicable. The problem is the CGI modules require a lot of the permanent config data from the .so as well, and the main app performs a whole lot of entirely