Technical article 100868

What system calls are available for locking data pages into memory?

OpenServer 5.0.0OpenServer 5.0.2OpenServer 5.0.4

Written · Last revised

Problem

Is there a way to programmatically lock data into memory in order to stop it from being potentially paged or swapped out to disk?

Solution

The following system calls are provided in either SCO OpenServer Release 5 or SCO UnixWare 2.1, which enable the locking of data or code into memory:

SCO OpenServer 5 and SCO UnixWare 2.1
-------------------------------------
lock(S), lock(2XNX)
      locks the entire process into memory.

plock(S), plock(2) locks code and/or data segments into memory. (doesn't include the locking of shared memory segments.)

shmctl(S), shmctl(2)
      locks a shared memory segment into memory
      (SHM_LOCK command).
SCO UnixWare 2.1 only
---------------------
memcntl(2)
      locks pages which contain the specified memory
      address range.
mlock(3C)
      similar to memcntl().
mctl(3BSD)
      similar to memcntl().

mlockall(3C) locks all pages mapped by an address space.

NOTE:     Although the routines memcntl(), mlock(), and mlockall()
          are included in SCO OpenServer Release 5, they are currently
          undocumented and their use is therefore unsupported.

From the Xinuos technical article database, record 100868. Reproduced with permission. The original is at www.sco.com/ta/100868, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.