![]() |
|
||||
POSIX 1.b Migration Guide |
Memory Locking
The memory locking interface has changed from Draft 9 to POSIX.1b. Some Draft 9 facilities have been discontinued (see below), while a new feature has been introduced to restrict memory locks to the current address space.
For additional information, refer to "Changes from Draft 9 to POSIX.1b" later in this chapter.
Locking the Specific Address Space
The ability to restrict memory locking for data, text, or stack segments of a process under Draft 9 (DATALOCK, TXTLOCK, STKLOCK flags) no longer exists. The only behavior supported is the ability to lock a specified address range (REGLOCK flag in Draft 9) and the entire process address space (PROLOCK flag in Draft 9).
Two new functions have been introduced to lock and unlock the entire address space, instead of using the PROLOCK flag. The following example illustrates their use and comparison to Draft 9 code.
Draft 9 Code
Equivalent POSIX.1b Code
Locking Future Growth
When locking the entire address space, Draft 9 guaranteed that subsequent growth would also be locked. POSIX.1b provides two flags, MCL_CURRENT and MCL_FUTURE. These flags request locking current pages or future pages, respectively. Under LynxOS, MCL_CURRENT locks current as well as future pages.
The MCL_FUTURE flag by itself locks only future pages, not current ones. It would be unusual for an application writer to request this flag by itself.
Memory Locking Flags Flag LynxOS Semantics Lock current as well as future pages Same as MCL_CURRENT Locks only future pages, not current
Draft 9 Code
Equivalent POSIX.1b Code
Changes from Draft 9 to POSIX.1b
Memory-Locking Interface Draft 9 POSIX.1b No Equivalent No Equivalent mlockall(MCL_CURRENT|MCL_FUTURE} or No Equivalent
Locking Flags
Draft 9 allows processes to lock their data, text, or stack segments. There is no support for such functionality in POSIX.1b. The flags used are:
Multiple Locks
Multiple memory locks can be set for a given region under Draft 9. There are no semantics for multiple locking in POSIX.1b. Memory locking functions can be invoked multiple times for a given address range, but still act as a single lock and are removed by a single unlock.
Locking/Unlocking the Entire Process
In Draft 9, the PROLOCK flag was used with memlk() and memunlk() to specify the entire process address space. In POSIX.1b, there are two new functions, mlockall() and munlockall(), for this purpose.
Current/Future Locking
In Draft 9, future memory growth was automatically locked with the PROLOCK flag. POSIX.1b provides a flag to request whether current or future pages be locked, with the MCL_CURRENT and MCL_FUTURE values, respectively. Under the LynxOS implementation, the MCL_CURRENT flag locks current as well as future pages. The following table shows the meaning of these flags.
Memory Locking Flags Flag LynxOS Semantics Lock current as well as future pages Same as MCL_CURRENT Lock only future pages, not current
Interoperability
The memory locking facilities for both Draft 9 and POSIX.1b are based on the same code in LynxOS.
![]() LynuxWorks, Inc. 855 Branham Lane East San Jose, CA 95138 http://www.lynuxworks.com 1.800.255.5969 |
![]() |
![]() |
![]() |
![]() |