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.
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
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
2. Programming
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
3. Programming
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
4. Programming
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
5. UNIX for Dummies Questions & Answers
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
6. Linux
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
7. UNIX for Dummies Questions & Answers
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
8. Programming
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
9. Programming
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
10. AIX
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
SHMAT(2) BSD System Calls Manual SHMAT(2)
NAME
shmat, shmdt -- map/unmap shared memory
SYNOPSIS
#include <sys/shm.h>
void *
shmat(int shmid, const void *shmaddr, int shmflg);
int
shmdt(const void *shmaddr);
DESCRIPTION
shmat() maps the shared memory segment associated with the shared memory identifier shmid into the address space of the calling process. The
address at which the segment is mapped is determined by the shmaddr parameter. If it is equal to 0, the system will pick an address itself.
Otherwise, an attempt is made to map the shared memory segment at the address shmaddr specifies. If SHM_RND is set in shmflg, the system will
round the address down to a multiple of SHMLBA bytes (SHMLBA is defined in <sys/shm.h> ). A shared memory segment can be mapped read-only by
specifying the SHM_RDONLY flag in shmflg. shmdt() unmaps the shared memory segment that is currently mapped at shmaddr from the calling
process' address space. shmaddr must be a value returned by a prior shmat() call. A shared memory segment will remain existant until it is
removed by a call to shmctl(2) with the IPC_RMID command.
RETURN VALUES
shmat() returns the address at which the shared memory segment has been mapped into the calling process' address space when successful,
shmdt() returns 0 on successful completion. Otherwise, a value of -1 is returned, and the global variable errno is set to indicate the error.
ERRORS
The shmat() system call will fail if:
[EACCES] The calling process has no permission to access this shared memory segment.
[EINVAL] shmid is not a valid shared memory identifier. shmaddr specifies an illegal address.
[EMFILE] The number of shared memory segments has reached the system-wide limit.
[ENOMEM] There is not enough available data space for the calling process to map the shared memory segment.
The shmdt() system call will fail if:
[EINVAL] shmaddr is not the start address of a mapped shared memory segment.
LEGACY SYNOPSIS
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
The include files <sys/types.h> and <sys/ipc.h> are necessary for both functions.
SEE ALSO
mmap(2), shmctl(2), shmget(2), compat(5)
BSD
August 17, 1995 BSD