Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > D


HP-UX 11i Version 3: February 2007

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index


datalock() — lock process into memory after allocating data and stack space


#include <sys/lock.h>

int datalock(size_t datsiz, size_t stsiz);


datalock() allocates at least datsiz bytes of data space and stsiz bytes of stack space, then locks the program in memory. The data space is allocated by malloc() (see malloc(3C)). After the program is locked, this space is released by free() (see malloc(3C)), making it available for use. This allows the calling program to use that much space dynamically without receiving the SIGSEGV signal.

The effective user ID of the calling process must be super-user or be a member of or have an effective group ID of a group having PRIV_MLOCK access to use this call (see setprivgrp(2) in getprivgrp(2)).


The following call to datalock() allocates 4096 bytes of data space and 2048 bytes of stack space, then locks the process in memory:

datalock (4096, 2048);


datalock() returns -1 if malloc() cannot allocate enough memory or if plock() returned an error (see plock(2)).


Multiple datalocks cannot be the same as one big one.

Methods for calculating the required size are not yet well developed.


datalock() was developed by HP.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.