How to attach a linked list to the shared memory?


 
Thread Tools Search this Thread
Top Forums Programming How to attach a linked list to the shared memory?
# 1  
Old 04-09-2010
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. So please help me out.
# 2  
Old 04-09-2010
Quote:
Originally Posted by jimmyuk
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. So please help me out.
What do you mean by "attach the linked list to shared memory"? Do you want some region of shared memory to be in the linked list somehow, or do you want to create a linked list that resides in the shared memory so that other processes can use it?

If it's the latter, you need to "manage" the shared memory yourself and create the various data structures your linked list needs, moving them into shared memory where appropriate.

However, that seems like a fairly large undertaking - why do you want to do this?

John G
# 3  
Old 04-09-2010
I am trying to access a linked list present in a shared memory by two threads simultaneously and just study the behaviour .
# 4  
Old 04-09-2010
Quote:
Originally Posted by jimmyuk
I am trying to access a linked list present in a shared memory by two threads simultaneously and just study the behaviour .
Just access it? Then someone else has created it, yes? There'll be a predefined way of getting access to the data structure (e.g. just casting the void* you get from shmat() & friends to a linked_list_t* or whatever), and then you can treat it like you would any other linked list.
# 5  
Old 04-09-2010
Quote:
Originally Posted by jimmyuk
I am trying to access a linked list present in a shared memory by two threads simultaneously and just study the behaviour .
Two threads in the same process already share memory, you don't need to set up a special shared memory area. If they were in different processes, you would.
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

shared memory with linked list??

is this possible, if so plz please share with me.. Correct English please, not Cyber-/Leetspeak (11 Replies)
Discussion started by: vijay_manpage
11 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. HP-UX

WAS 6.1 ND/Lawson ERP/HP-UX 11.23 PA-RISC - unable to attach shared memory segment

I'm not an HP-UX Admin professional, but rather a Lawson ERP installer. I'm looking for clues on how to troubleshoot this issue. I have WAS 6.1 ND running on HP-UX 11.23 PA-RISC with the Lawson ERP application . When I start the Lawson application, no errors arise. When I start WAS app server, an... (4 Replies)
Discussion started by: mrvitas
4 Replies

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

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

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