/g/ - Technology
install openbsd
[Make a Post]A call to mmap is guaranteed to return a certain number of complete pages. So make sure to directly allocate your memory with a call to mmap, perhaps by writing a custom allocator.
Also, use the sticky next time.
Also, use the sticky next time.
>>9878
Is there a solution that could be used cross-platform?
Right now this project supports both Linux and Windows.
On Windows I'm using VirtualLock() and VirtualUnlock().
Is there a solution that could be used cross-platform?
Right now this project supports both Linux and Windows.
On Windows I'm using VirtualLock() and VirtualUnlock().
>>9880
Yes, On POSIX systems I use mlock and munlock, and on Windows I use VirtualLock and VirtualUnlock.
Yes, On POSIX systems I use mlock and munlock, and on Windows I use VirtualLock and VirtualUnlock.
>>9909
Use HolyC
Use HolyC
Just in case anyone else is interested in doing this in their own software, I simply redesiged all my classes so that their buffers are allocated and managed externally, and they can all be locked and unlocked from one buffer.
[Catalog][Overboard][Update]
[Reply]0 files, 10 replies
From what I can tell, mlock(const void *addr, size_t len) locks pages and munlock(const void *addr, size_t len) unlocks them.
The man page says:
munlock() unlocks pages in the address range starting at addr and continuing for len bytes. After this call, all pages that contain a part of the specified memory range can be moved to external swap space again by the kernel.
Suppose I call mlock() on two different buffers, and I want to unlock one of them later in the program.
Is there a chance that both buffers may be unlocked by one call to munlock() if they are both on the same page boundary?
My current design has class constructors calling mlock() with the destructors calling munlock(), but I'm not sure if this is safe.
Any suggestions Nanons?