|
Home > Archive > Unix Programming > April 2006 > Proper use of mlock(2)
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Proper use of mlock(2)
|
|
| Daniel Rudy 2006-04-02, 7:42 pm |
|
What is the proper use of mlock(2)? In the man page, it states that the
addr param *should* be aligned on a page boundary. The question is how
do you find out if it is or isn't? Or better yet, how do you force an
allocation on a page boundary?
I can use getpagesize(2) to find out what the page size is, but with
FreeBSD and it's virtual address memory model, how do you force a memory
allocation in the virtual address space to align to a physical page
boundary?
My OS is FreeBSD 6.0.
Thanks.
--
Daniel Rudy
Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m
Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep
| |
| Thomas Maier-Komor 2006-04-02, 7:42 pm |
| -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Daniel Rudy wrote:
> What is the proper use of mlock(2)? In the man page, it states that the
> addr param *should* be aligned on a page boundary. The question is how
> do you find out if it is or isn't? Or better yet, how do you force an
> allocation on a page boundary?
>
> I can use getpagesize(2) to find out what the page size is, but with
> FreeBSD and it's virtual address memory model, how do you force a memory
> allocation in the virtual address space to align to a physical page
> boundary?
>
> My OS is FreeBSD 6.0.
>
> Thanks.
>
you don't have to care about virtual to physical mapping. If your
virtual address is a multiple of pagesize everything is fine. You cannot
force a malloc to return a multiple of pagesize as the base address of
the allocated memory block, but you can allocate a big enough block, so
that you can calculate an aligned address within that block.
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (SunOS)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFEKmgz6U+hp8PKQZIRAhZwAKC/JkccwNeDYNfmy9457FzZ6bvGVQCfQU/a
4hlFLvcBLsfhgDY2dd7Vd/A=
=Y5Jn
-----END PGP SIGNATURE-----
|
|
|
|
|