• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

how to share a 2d integer array

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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;
 
author
Posts: 23909
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ravindra koranga wrote:
It gives error assignment to expression with array type;



I am assuming "error" means compiler error? And that it is at line 5? ... if not, please provide the full compiler error messages.

As for line 5, obviously, that is not a valid array declaration. You are missing the data type.

Henry
 
ravindra koranga
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No its just a typo in this code. What I want is I have a 2d array of character pointers  for eg char *queue [10][10]. 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?
 
Henry Wong
author
Posts: 23909
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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).

Henry
reply
    Bookmark Topic Watch Topic
  • New Topic