FAQ Database Discussion Community


pointer in boost shared memory object

c++,pointers,boost,shared-memory
I am dealing with boost::interprocess::shared_memory_object and what I'm trying to achieve is like this. I define my own class which is called SharedMemory and in it, there is a method called CreateSharedMemory() which creates a memory block. I need to keep three arrays Foo a1[SIZE], Foo a2[SIZE] and Foo a3[SIZE]...

Sequential use of shared variable in Java

java,multithreading,swing,shared-memory
I am working on a java GUI application. On some event (eg. button click) I want to read large ammount of data from a file in a new worker thread and store it into shared variable. Then from this worker thread I want to invoke EDT (Event Dispatching Thread) and...

Running in Parallel on a Shared-Memory Quad-Core Computer using 4 threads

java,c++,multithreading,performance,shared-memory
Greetings noble community, I want to have the following loop: for(i = 0; i < MAX; i++) A[i] = B[i] + C[i]; This will run in parallel on a shared-memory quad-core computer using threads. The two alternatives below are being considered for the code to be executed by these threads,...

Passing pointers to APIs provided by DLL

dll,operating-system,shared-memory
I came to doubt after doing this. I had created a DLL in which APIs accepts pointers to some values from application. I am able to access those pointers in DLL. So i had a doubt how is memory allocated for functions present in DLL and called from application. It...

Dynamically allocated shared memory in CUDA. Execution Configuration

cuda,shared-memory
What does by this Nvidia means? Ns is of type size_t and specifies the number of bytes in shared memory that is dynamically allocated per block for this call in addition to the statically allocated memory; this dynamically allocated memory is used by any of the variables declared as an...

Playing with shmat and shm_open

c,linux,linux-kernel,shared-memory
I just read the manpages for shm_open and shmat and was trying out the following example. In a file test.c I do, int main(int argc, char **argv) { void *retval; long shmid = atol(argv[1]); retval = shmat(shmid, NULL, SHM_RDONLY); printf("%p\n", retval); } And in a wrapper file I do, int...

Large memory pages and fragmentation

linux,memory-management,shared-memory,ppc
I am using Linux + PPC64 where the memory page size is 64KiB. If I were to make two separate 32KiB allocations from within the same process, would that take up a single page in memory or two? Thanks!

Avoid variable duplication using fork() in C

c,multithreading,sockets,fork,shared-memory
I am implementing a server that serves multiple clients and I need some server's variable to be in shared memory so a client actually sees what another client has eventually edited. I tried looking around but I didn't understand if there is any way to achieve this by using fork()...

Shared Memory UNIX Segmentation Fault (fork()) in C++

c++,unix,segmentation-fault,fork,shared-memory
I have a problem with shared memory and processes. I attach an area to the shared memory, I make a child proccess but when I try to modify the shared memory area in the father process I only get segmentation fault, it just can be modified in the child. .h...

CUDA shared memory bank conflicts report higher

cuda,gpu,shared-memory,bank-conflict
I've been working on optimizing some code and ran into an issue with the shared memory bank conflict report with the CUDA Nsight performance analysis. I was able to reduce it to a very simple piece of code that Nsight reports as having a bank conflict, when it doesn't seem...

Establishing shared memory between different proccesses with limited resources?

c++,c,process,shared-memory
After some painful debugging, I realized trying to use mmap to store a class in shared memory is horrendously stupid. So, say that I have a class with something like 5 variables (strings and ints) that I would like to be accessible to all running processes. How could I go...

why shared memory is faster than global memory?

cuda,shared-memory
is that difference in speed due to technology with which both were made of( i read that shared memory is a scratchpad memory that is mainly SRAM memory while global memory is typically a DRAM memory)? what if both were made with same technology, will be any differences in performance...

Only half of the shared memory array is assigned

cuda,shared-memory,nsight
I see only half of the shared memory array is assigned, when I use Nsight stepped after s_f[sidx] = 5; __global__ void BackProjectPixel(double* val, double* projection, double* focalPtPos, double* pxlPos, double* pxlGrid, double* detPos, double *detGridPos, unsigned int nN, unsigned int nS, double perModDetAngle, double perModSpaceAngle, double perModAngle) { const...

IPC through a SHM for C++ and concurrent memory accesses

c++,multithreading,shared-memory
I am trying to improve the performance of a framework I use. Currently it makes use of a shared memory space(shm), to allow for inter-process communication between two C++ threads. Control to the SHM is passed through a semaphore. This is the current system which works quite well, albeit slightly...

Accessing shared memory in a process after shmdt() and before shmctl(shmid, ipc_RMID, 0)

c,linux,process,shared-memory
Assuming I have a pointer *p to a shared memory previously allocated. If one of the processes calls shmdt() to detach the shared memory segment, and then tries to assign a value e.g. : *p = 0; before calling shmctl(shmid, IPC_RMID, 0) for destruction. Will doing so result in an...

purposely causing bank conflicts for shared memory on CUDA device

cuda,gpu,shared-memory,bank-conflict
It is a mystery for me how shared memory on cuda devices work. I was curious to count threads having access to the same shared memory. For this I wrote a simple program #include <cuda_runtime.h> #include <stdio.h> #define nblc 13 #define nthr 1024 //[email protected] __device__ int inwarpD[nblc]; __global__ void kernel(){...

Expected behaviour of shm_unlink?

c++,ipc,shared-memory
Does shm_unlink store a reference count to determine when to delete the file? I ask because I have the following: Writer: #include <iostream> #include <sys/mman.h> #include <unistd.h> #include <fcntl.h> #include <cstdio> using namespace std; void Sleep(int ms) { usleep(ms * 1000); } int main() { int fd = shm_open("/Test", O_CREAT...

Can't print on standard output after using shmat

c,unix,output,shared-memory,fgets
So in this code puts can't display the output. If I remove the fgets line, it prints lola but if I try to read and write on shm, nothing happens. How can I solve this? #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/ipc.h> #include <sys/sem.h> #include <sys/types.h> #define SHMSZ 4096...

c - writing to shared memory segment causes segmentation fault

c,segmentation-fault,shared-memory
I'm having problems with writing to shared memory segment. Here's the code: EDIT: after I removed that == (mistake), now I'm getting Bus Error (Core Dumped), here's the edited code: // Struct for data from shared memory typedef struct { pthread_mutex_t shared_mutex; int last_used_job_id; } shared1; static void *job_generator(void *param)...

Initialize array starting from specific address in memory - C programming

c,arrays,shared-memory
Do you have idea how to initialize array of structs starting from specific address in memory (not virtual, physical DDR memory). I am working on implementation of TxRx on SoC (ARM-FPGA). Basically ARM (PS) and FPGA (PL) communicate to each other by using shared RAM memory. Currently I am working...

Python multiprocess share memory vs using arguments

python,data,pandas,multiprocessing,shared-memory
I'm trying to get my head around what is the most efficient and less memory consuming way to share the same data source between different process. Imagine the following code, that simplify my problem. import pandas as pd import numpy as np from multiprocessing import Pool # method #1 def...

Python multiprocessing shared dict inside a class

python,dictionary,shared-memory
I want to understand how multiprocessing and manager works in order to shared memory I have a class with a dictionary created on class.init I want to use multiprocessing in order to call a class function which fill the dictionary (every process add a different key). import multiprocessing as mp...

shared memory performance and protection from other processes

linux,security,shared-memory
I am trying to implement a JIT compiler (I have very geeky hobbies). I would like to have one main process that keeps some persistent variables, and a second process (that has been compiled just-in-time) that does some computation and can access and write on the persistent variables. The second...

opencl - use image object with local memory

memory,opencl,gpu,shared-memory,gpgpu
i'm trying to program with opencl. There are two types of memory object. one is buffer and another one is image. some blogs and web site,white papers say 'image object is little bit faster that buffer because of cache'. i'm trying to use image object and the reason for that...

How to load data in global memory into shared memory SAFELY in CUDA?

c++,cuda,shared-memory
My kernel: __global__ void myKernel(float * devData, float * devVec, float * devStrFac, int Natom, int vecNo) { extern __shared__ float sdata[]; int idx = blockIdx.x * blockDim.x + threadIdx.x; float qx=devVec[3*idx]; float qy=devVec[3*idx+1]; float qz=devVec[3*idx+2]; __syncthreads();//sync_1 float c=0.0,s=0.0; for (int iatom=0; iatom<Natom; iatom += blockDim.x) { float rtx =...

Reduction(op:var) has the same effect as shared(var)

c++,openmp,shared-memory,shared,reduction
I've tried this code snippet for reduction(op:var) proof of concept, it worked fine and gave a result = 656700 int i, n, chunk; float a[100], b[100], result; /* Some initializations */ n = 100; chunk = 10; result = 0.0; for (i=0; i < n; i++) { a[i] = i...

OnSharedPreferenceChangeListener callback is not called across applications

android,sharedpreferences,shared-memory
We have two apps with same sharedUserId and same signature. So one application can write to others' SharedPreferences without any problem (tested). But the problem is that when App A writes something to App B's shared preferences, OnSharedPreferencesChangedListener's in App B is not get called. Both apps were running during...

C Socket/Client fork(), share struct memory

c,sockets,struct,fork,shared-memory
I'm trying to share the memory of a struct on my C server, got the following code // Before the main struct Esami { char nome[20]; char cognome[20]; char matricola[20]; char voto[20]; }; struct Appelli { int stato; char dipartimento[20]; char cdl[20]; char nomeEsame[20]; char data[20]; struct Esami esame[10]; int...