![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shared memory in shared library | DreamWarrior | High Level Programming | 12 | 05-30-2007 01:33 PM |
| memory sharing - not shared memory - | elzalem | High Level Programming | 9 | 05-02-2007 04:45 AM |
| help with shared memory | ddx08 | High Level Programming | 6 | 04-06-2007 06:53 AM |
| load dynamic and shared library in kernel | mtaghiloo | Linux | 0 | 08-01-2005 07:34 AM |
| Shared memory shortage but lots of unused memory | cjcamaro | UNIX for Advanced & Expert Users | 1 | 10-13-2004 02:10 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
dynamic shared memory
Hi
I need help regarding shared memory. I need to maintain the following structure in shared memory. struct linked_list_header{ pid_t pid; pthread_mutex_t lock; int top; int end; int free; NODE *ptr } The node structure is as follows struct NODE { int index; int prv; int nxt; void *buffer; } Is it possible to maintain this dynamic linked_list_header in shared memory. I tried to maintain the same BUT I am not able to share the NODE structre data among the processes. Thanks a lot |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
If you called malloc to create linked_list_header->ptr, then the address returned by malloc is private to the calling (the process that calls malloc) process. Same with NODE->buffer. You will have to allocate these things in shared "by hand" without calling malloc.
|
|
#3
|
|||
|
|||
|
Thanks a Jim
I corrected my program to share the memory instead of malloc, Now it is working fine. I need another clarification regarding the same. During run time, If I need more shared memory, Is it possible to mmap the increased size of dynamic memory while retaining the contents of previously mmaped memory. ( like realloc's functionality which preserves previously allocated memory contents) Thanks once again |
|
#4
|
|||
|
|||
|
You mmap a second memory area. However mmap is not like malloc or realloc.
It works using pages of memory, not bytes. Create a really large memory block to start with. It sounds like you're using Linux. Linux supports system V IPC XPG4.2 calls: sys/shm.h provides support for shmat(), shmget(), etc.. You may also want to look at those calls. |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | |
| Display Modes | |
|
|