Re: A shared library which attaches a shared segment - what's the right way??
From: Paul Pluzhnikov (ppluzhnikov-nsp_at_charter.net)
Date: 12/25/04
- Previous message: Boaz: "A shared library which attaches a shared segment - what's the right way??"
- In reply to: Boaz: "A shared library which attaches a shared segment - what's the right way??"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 25 Dec 2004 13:51:53 -0800
"Boaz" <boazter@hotmail.com> writes:
> I wrote a shared memory library in c++ which using 'shmget' and 'shmat'
> to allocate a shared memory segment.
> The varibale which attaches the shared memory segment using 'shmat' is
> defined static.
> I have two questions:
> Since the latrer variable is static, is it possible for each process
> which links this lobrary, to use this shared segment?
The visibilty of the variable has *absolutely* nothing to do with
whether the processes can use this shared memory.
You continue to demonstrate complete lack of understanding of how
UNIX virtual memory works. I advise you (for the last time) to read
an introductory book on the subject.
> If i want to remove this shared segment from memory, do i need to use
> both 'shmdt' and 'shmctl', or only 'shmctl'?
Remove this segment from memory of the process? Use shmdt.
Remove it from the system (so no other process can attach to it)?
Use shmctl(..., IPC_RMID).
Note that the segment will not be actually destroyed until last
attached process exits or performs shmdt.
Cheers,
-- In order to understand recursion you must first understand recursion. Remove /-nsp/ for email.
- Previous message: Boaz: "A shared library which attaches a shared segment - what's the right way??"
- In reply to: Boaz: "A shared library which attaches a shared segment - what's the right way??"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|