Next | Prev | Up | Top | Contents | Index

Locking Functions

You use one of two functions to lock segments into physical memory:

mpin()

Locks a specified range of pages into memory

plock()

Locks all program text, or all data, or the entire address space
The two functions have the same effect. They differ only in how you specify the pages to be locked. (Refer to the mpin(2) and plock(2) reference pages.)

Using mpin() you have to calculate the starting address and the length of the segment to be locked. It is relatively easy to calculate the starting address and length of global data or of a mapped segment, but it can be awkward to learn the starting address and length of program text or of stack space. The best use of mpin() is to lock a mapped memory segment, since you know its starting address and length immediately after creating it.

Both plock() and mpin() define all pages of the specified segments before locking them. When virtual swap is in use, it is possible to receive a SIGKILL exception while locking because there was not enough swap space to define all pages (see "Delayed and Immediate Space Definition").

Locking pages in memory of course reduces the memory that is available for all other programs in the system. Locking a large program increases the rate of page faults for other programs.

You use either munpin() or punlock() to unlock pages, allowing the kernel to reclaim them when necessary. Locked pages of an address space are unlocked when the last process using the address space terminates.


Next | Prev | Up | Top | Contents | Index