Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 03 Dec 2011 09:38:12 -0800
From:      Julian Elischer <julian@freebsd.org>
To:        Filippo Sironi <filippo.sironi@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: mmap implementation for cdev
Message-ID:  <4EDA5E84.1030605@freebsd.org>
In-Reply-To: <A51F9B30-A71A-49A5-B684-16EC3C127BC9@gmail.com>
References:  <A51F9B30-A71A-49A5-B684-16EC3C127BC9@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 12/3/11 12:42 AM, Filippo Sironi wrote:
> Dear all,
>
> I've a strange problem I cannot understand...
> I implemented a piece of code within the FreeBSD 7.2 kernel that basically allocate a per-thread memory page to store a certain amount of information that must be read and written without crossing user to kernel and kernel to user boundaries.
> To read and write the memory page I decided to allocate it in kernel space and then mmap'ing it to user space using a "virtual cdev" as an entry point for user space threads. The implementation of the mmap I came up with is really trivial, I basically do:
>
> *paddr = vtophys(curthread->private_info);
>
> Now for the problem.
> I enter the mmap and private_info is the correct kernel space virtual address, each thread as its own address and the physical address - returned by vtophys - is different too. The problem is that when I come back to user space all the threads write in memory page mapped by the first thread that called the mmap leaving their memory pages untouched.
>
> This problem bugs me but I cannot find a solution. I don't really understand the behavior.
>
each thread needs to store a different address as the base of it's 
memory..
the memory map of a process is just that.. the memory map of the PROCESS

All threads see the same map.


> Any ideas?
> Thanks a lot,
> Filippo
>
>
> _______________________________________________
> freebsd-hackers@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
>
>




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4EDA5E84.1030605>