shm_map questions

Laurie Jennings laurie_jennings_1977 at yahoo.com
Thu Apr 11 14:58:22 UTC 2013


Im working on a simple project that shares a memory segment between a user processand a kernel module. I'm having some problems with shm_map and there doesn't seem to be much info on it.
Im not sure what happened to the memory when the user process that creates it terminates.  I have some questions.
1) Does the kernel mapping keep the segment from being garbage collected when the use process that creates it terminated? I've experienced shm_unmap() panic when tryingto unmap a segment
scenario:  
User process Maps SegmentKernel maps it  with shm_map()User Process TerminatesKernel tries to shm_unmap() and it panics.
2) Is there a way for the kernel process to know when the user process has goneaway? A ref count?
3) Does a SHM_ANON segment persist as long as the kernel has it mapped, or doesit get garbage collected when the creating user process terminates?
4) When using a named segment, can the kernel "reuse" a mapping for a new userprocess?
Example:
User process creates shm segment with path /fooKernel Maps shm segment with shm_map()User process terminates.User process runs again, opening segment /foo
Does the kernel need to re-map, or is the original mapping valid?
Thanks!Laurie


More information about the freebsd-net mailing list