![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Apr 2008
Posts: 1
Rep Power: 0
![]() |
structure with an array in shared memory
Hi. I'm having difficulties with shared memory.
I have a structure which looks like this: c Syntax (Toggle Plain Text)
Afterwards I use fork(), the child jumps into a function which attaches the shared memory ID of the structure, mallocs the *sharearr pointer(I pass on the size to the function via an argument),and fills it with integers ranging from 1 to (size+1). The problem comes up when I try to access the array with the parent function(the parent is suspended until the child is done filling the array). The pointers seem to be actually shared, I just can't get access to any of the members of the array. Could someone please tell me what I'm doing wrong? |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 816
Rep Power: 4
![]() |
Re: structure with an array in shared memory
I haven't used shmget, but I would imagine you need to allocate the sharearr array using smget as well. This means that your structure would need to contain the sharearr id rather than the pointer. Then your calling process would have to call shmat to get a pointer to the memory.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| queue - shared memory | programmingnoob | C++ | 4 | Mar 26th, 2007 8:19 PM |
| dynamic array of structure pointer | atogrev | C | 7 | Oct 27th, 2006 2:23 PM |
| Masm | rsnd | Assembly | 4 | May 20th, 2006 9:05 PM |
| address memory in an array | b1g4L | C++ | 9 | Feb 5th, 2006 2:33 AM |
| Installing IPB 2.03 | bh4575 | Other Web Development Languages | 0 | Apr 23rd, 2005 2:36 AM |