$LCKPAG, or Lock Pages in Memory, is a system service that locks a page or range of pages in memory.
The Lock Pages in Memory service locks a page or range of pages in memory. The specified virtual pages are forced into the working set and then locked in memory.
A locked page is not swapped out of memory if the working set of the process is swapped out. These pages are not candidates for page replacement and in this sense are locked in the working set as well.
If more than one page is being locked and you need to determine specifically which pages were previously locked, the pages should be locked one at a time. If an error occurs while the $LCKPAG service is locking pages, the return array, if requested, indicates the pages that were successfully locked before the error occurred. If no pages are locked, both longwords in the return address array contain the value –1.
On Alpha and Integrity systems, if you are attempting to lock executable code, you should issue multiple $LCKPAG calls: one to lock the code pages and others to lock the linkage section references into these pages.
int sys$lckpag (struct _va_range *inadr, struct _va_range *retadr, unsigned int acmode);
Starting and ending virtual addresses of the range of pages to be locked. The inadr argument is the address of a 2-longword array containing, in order, the starting and ending process virtual addresses. Only the virtual page number portion of each virtual address is used; the low-order byte-within-page bits are ignored.
On VAX systems, if the starting and ending virtual addresses are the same, a single page is locked.
Starting and ending process virtual addresses of the pages that $LCKPAG actually locked. The retadr argument is the address of a 2-longword array containing, in order, the starting and ending process virtual addresses.
Access mode to be associated with the pages to be locked. The acmode argument is a longword containing the access mode. The $PSLDEF macro defines the four access modes.
The most privileged access mode used is the access mode of the caller. For the $LCKPAG service to complete successfully, the resultant access mode must be equal to or more privileged than the access mode already associated with the pages to be locked.
Condition Values Returned
|SS$_WASCLR||The service completed successfully. All of the specified pages were previously unlocked.|
|SS$_WASSET||The service completed successfully. At least one of the specified pages was previously locked.|
|SS$_ACCVIO||The input array cannot be read; the output array cannot be written; the page in the specified range is inaccessible or nonexistent; or an attempt to lock pages was made by a caller whose access mode is less privileged than the access mode associated with the pages.|
|SS$_LCKPAGFUL||The system-defined maximum limit on the number of pages that can be locked in memory has been reached.|
|SS$_LDWSETFUL||The locked working set is full. If any more pages are locked, not enough dynamic pages will be available to continue execution.|
|SS$_NOPRIV||The process does not have the privilege to lock pages in memory.|
|SS$_PAGOWNVIO||The pages could not be locked because the access mode associated with the call to $LCKPAG was less privileged than the access mode associated with the pages that were to be locked.|
Required Access or Privileges
The calling process must have PSWAPM privilege to lock pages into memory.