int munlock(const void *addr, size_t size);
This system call implements the POSIX.1b munlock function, which unlocks a range of previously locked memory.Neither the start address of the specified region nor its length need to be page-aligned; this function will lock all pages overlapping the specified region.
In raw DOS mode and VCPI mode, this function works as the POSIX standard indicates; however, since MOSS currently does not support demand paging (only demand loading of executables and demand zeroing of heap memory), unlocking memory currently has no real effect.
In DPMI mode, munlock does not work quite as described by POSIX, because DPMI keeps a ``lock count'' on locked pages and only unlocks a page when the lock count has returned to zero. Thus, if you unlock a page of memory that was previously locked more than once, whereas POSIX specifies that the page should be unlocked on the first call to munlock, under DPMI it will only be unlocked after two calls (or however many times the page was locked). (MOSS could emulate true POSIX behavior, but is it worth the trouble?)
- addr
- The start address of the region to unlock.
- size
- The size of the region to unlock, in bytes.
Returns 0 if successful, or -1 on error, in which case errno indicates the error.