api for sharing memory from kernel to userspace?

Terry Lambert tlambert2 at mindspring.com
Fri May 21 19:06:11 PDT 2004


Alfred Perlstein <alfred at freebsd.org> writes:
> I need to share about 100megs of memory between kernel and userspace.
> 
> The memory can not be paged and should appear contig in the process's
> address space.  Any suggestions?
> 
> I need a way to either:
> map user memory into the kernel's address space.
> map kernel memory into the user's address space.
> 
> I was looking at pmap_qenter() but it didn't see attractive because
> it's for "short term mappings", this mapping will exist for quite a
> while.

Given your "non-paged" requirement, the allocation needs to take place
in the kernel.

Visible in a single process, or in all of them?

If all of them, set the PG_U bit; it will have the same address in user
space as it does in the kernel, and be visible to all processes.

If only one of them, the best general solution is to use a pseudo-device,
and support mmap() on it.

-- Terry


More information about the freebsd-hackers mailing list