api for sharing memory from kernel to userspace?
Bruce M Simpson
bms at spc.org
Thu May 20 03:17:32 PDT 2004
On Wed, May 19, 2004 at 03:29:09PM -0700, Steve Watt wrote:
> >On Wed, May 19, 2004 at 05:29:07AM -0700, Alfred Perlstein wrote:
> >+> 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?
> >+>
>
> The way we accomplished this in some other operating system was to
> create a shared memory segment with an implementation-reserved
> name, and then have the application shm_open the name and mmap it in.
>
> Shouldn't be hard with a device driver.
This sounds like the way to go.
The way I achieved this with a PCMCIA memory card was to kmem_alloc_nofault()
a range and then pmap_map() it, then handle mmap() as per the regular
character device case.
Do bear in mind that 100 megs is quite large in relative terms, so it's
possible that kmem_alloc_nofault() would fail.
Regards,
BMS
More information about the freebsd-hackers
mailing list