plock Subroutine

Purpose

Locks the process, text, or data in memory.

Library

Standard C Library (libc.a)

Syntax

#include <sys/lock.h>

int plock ( Operation)
int Operation;

Description

The plock subroutine allows the calling process to lock or unlock its text region (text lock), its data region (data lock), or both its text and data regions (process lock) into memory. The plock subroutine does not lock the shared text segment or any shared data segments. Locked segments are pinned in memory and are immune to all routine paging. Memory locked by a parent process is not inherited by the children after a fork subroutine call. Likewise, locked memory is unlocked if a process executes one of the exec subroutines. The calling process must have the root user authority to use this subroutine.

A real-time process can use this subroutine to ensure that its code, data, and stack are always resident in memory.

Note: Before calling the plock subroutine, the user application must lower the maximum stack limit value using the ulimit subroutine.

Parameters

Item Description
Operation Specifies one of the following:
PROCLOCK
Locks text and data into memory (process lock).
TXTLOCK
Locks text into memory (text lock).
DATLOCK
Locks data into memory (data lock).
UNLOCK
Removes locks.

Return Values

Upon successful completion, a value of 0 is returned to the calling process. Otherwise, a value of -1 is returned and the errno global variable is set to indicate the error.

Error Codes

The plock subroutine is unsuccessful if one or more of the following is true:

Item Description
EPERM The effective user ID of the calling process does not have the root user authority.
EINVAL The Operation parameter has a value other than PROCLOCK, TXTLOCK, DATLOCK, or UNLOCK.
EINVAL The Operation parameter is equal to PROCLOCK, and a process lock, text lock, or data lock already exists on the calling process.
EINVAL The Operation parameter is equal to TXTLOCK, and a text lock or process lock already exists on the calling process.
EINVAL The Operation parameter is equal to DATLOCK, and a data lock or process lock already exists on the calling process.
EINVAL The Operation parameter is equal to UNLOCK, and no type of lock exists on the calling process.