I wish to share an array of integer among a parent and all its children and synchronise them. Only the children will process the array. Mutual exclusion is needed to ensure that they do not change the same array element. I tried this.
It gives error assignment to expression with array type;
No its just a typo in this code. What I want is I have a 2d array of character pointers for eg char *queue . The parent fills first column of this array. Then I wish to share it among the children for processing. Children may fill more elements in this array. What is the best way to do it.One way I can think of is to use shmget() function to request a shared memory and then copy this array to the shared memory in parent. Is there any better way to do this?
ravindra koranga wrote:Is there any better way to do this?
IMHO, the two easiest way to share live data structures are via shared memory, or via mmap files. I came from a SunOS background, so prefer the latter, but they both should be equally fine (in fact, under the hood, with many implementations, they route to the same code in the OS).