shared memory with linked list??


 
Thread Tools Search this Thread
Top Forums Programming shared memory with linked list??
# 1  
Old 06-25-2010
shared memory with linked list??

is this possible, if so plz please share with me..

Moderator's Comments:
Mod Comment Correct English please, not Cyber-/Leetspeak

Last edited by pludi; 06-25-2010 at 02:46 AM.. Reason: corrected spelling
# 2  
Old 06-25-2010
This is entirely possible.

  • Create shared memory region
  • Place the head of the linked list there at a known location (e.g. at the start of the shared region), being careful to make sure that both the linked list itself and the data referenced by it are in the shared memory, not on your heap/stack.
# 3  
Old 06-25-2010
MySQL Thank you but...,

a bit more programmatical explanation will do.!!
# 4  
Old 06-25-2010
Quote:
Originally Posted by vijay_manpage
a bit more programmatical explanation will do.!!
"You're welcome"?

The thing (or rather, the combination of things) you're asking about is quite extensive and a bit niche. You'll have to do research for yourself on this one - don't expect anyone to hand the answers to you on a plate.

There are tutorials on the web for both subjects, so take a look. Search for "beej's guide to ipc" and you'll find some good info about shared memory, and it won't be hard to find examples of how to create linked lists. Combine these two (remembering that you can't use the linked list to "point" to data in your program's address space, you have to ship it all out to the shared memory region) and you're there.
# 5  
Old 06-25-2010
Bug coool dude..

Tank you
# 6  
Old 06-25-2010
I do not think that this scenario is possible on protected memory managed systems ...
Like Linux / any flavor of UNIX .

If you recall that a shared memory is identified through key_t type of datatype and are operated through syscalls.

You can not perform memory operations like you do on normal program variables (be it a heap, stack, .bss, .data/ro etc).
Like &<my_variable>

Now a typical linked list node looks like:

Code:
struct myNode {
   int info;

      // ...

   struct myNode *nextNode;
};

Now could anyone explain , if you could populate the pointer (nextNode) with an address of a shared memory? If yes how, I want to learn. Smilie

However, the same is possible (and very much possible) possible on a flat memory managed systems like VxWorks. As a food for though just think how?
# 7  
Old 06-25-2010
Tools @JohnGraham

answer @praveen if you could..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Create shared libs on AIX (with certain libs which are statically linked)

I want to create a shared lib with certain libs statically linked to it. I can generate a fully shared lib as follows: gcc -maix64 -DHAVE_CONFIG_H -I. -I./src -DHAVE_OPENSSL -I/usr/include/openssl -I/usr/include -I/usr/include/apr-1 -D_LARGEFILE64_SOURCE -I/usr/java8_64/include -shared -o... (0 Replies)
Discussion started by: amandeepgautam
0 Replies

2. Programming

Shared library with acces to shared memory.

Hello. I am new to this forum and I would like to ask for advice about low level POSIX programming. I have to implement a POSIX compliant C shared library. A file will have some variables and the shared library will have some functions which need those variables. There is one special... (5 Replies)
Discussion started by: iamjag
5 Replies

3. Programming

How to attach a linked list to the shared memory?

Hi all, I have been working on shared memory. I have created the shared memory and a linked list of 5 nodes. Now I want to attach the linked list to shared memory. When we attach a shared memory it returns a void pointer, but here I am in a fix , how to relate this void pointer to linked list.... (4 Replies)
Discussion started by: jimmyuk
4 Replies

4. UNIX for Dummies Questions & Answers

How to attach a linked list to the shared memory?

Hi all, I have been working on shared memory. I have created the shared memory and a linked list of 5 nodes. Now I want to attach the linked list to shared memory. When we attach a shared memory it returns a void pointer, but here I am in a fix , how to relate this void pointer to linked list.... (1 Reply)
Discussion started by: jimmyuk
1 Replies

5. Linux

change the memory address of ld.linux-so in a dynamically linked process

hi, For some special reason , I'd like to control the memory address for the shared libraries in my dynamically linked process. And it is the "ld" which interpret the dynamically linked library, and in my system, the "ld-linux.so.2" is put at 0x00812000. Then I use "prelink -r" command to... (3 Replies)
Discussion started by: zerocool_08
3 Replies

6. UNIX for Dummies Questions & Answers

change the memory address of ld.linux-so in a dynamically linked process

hi, For some special reason , I'd like to control the memory address for the shared libraries in my dynamically linked process. And it is the "ld" which interpret the dynamically linked library, and in my system, the "ld-linux.so.2" is put at 0x00812000. Then I use "prelink -r" command to change... (0 Replies)
Discussion started by: zerocool_08
0 Replies

7. Programming

Shared memory for shared library

I am writing a shared library in Linux (but compatible with other UNIXes) and I want to allow multiple instances to share a piece of memory -- 1 byte is enough. What's the "best" way to do this? I want to optimize for speed and portability. Obviously, I'll have to worry about mutual exclusion. (0 Replies)
Discussion started by: otheus
0 Replies

8. Programming

Shared memory in shared library

I need to create a shared library to access an in memory DB. The DB is not huge, but big enough to make it cumbersome to carry around in every single process using the shared library. Luckily, it is pretty static information, so I don't need to worry much about synchronizing the data between... (12 Replies)
Discussion started by: DreamWarrior
12 Replies

9. Programming

memory sharing - not shared memory -

hi, this is the problem: i want to swap a linked list between 4 processes (unrelated), is there any way i can do that just by sending a pointer to a structure? //example typedef struct node { int x; char c; struct node *next; } node; or i should send the items ( x,c ) by... (9 Replies)
Discussion started by: elzalem
9 Replies

10. UNIX for Advanced & Expert Users

Shared memory shortage but lots of unused memory

I am running HP-UX B.11.11. I'm increasing a parameter for a database engine so that it uses more memory to buffer the disk drive (to speed up performance). I have over 5GB of memory not being used. But when I try to start the DB with the increased buffer parameter I get told. "Not... (1 Reply)
Discussion started by: cjcamaro
1 Replies
Login or Register to Ask a Question