[comp.unix.wizards] Keeping pages from getting swapped out.

chandra@thiazi.cs.cornell.edu (Tushar D Chandra) (03/07/90)

Hi,

I'm writing an application in which I need to keep a small process (1-2 pages)
from getting swapped out. The following solutions are unacceptable:

1. modifying the kernel
2. writing the process as a device driver (see 1). I need the process to be an
	"honest to god" user process.

Does anyone out there know how to do this? If I remember correctly, older
versions of UNIX *had* a system call (lock, I think) which if executed by a
process run by root would solve my problem.

Thanks in advance.

-Tushar Chandra
(e-mail chandra@cs.cornell.edu)

wsinpdb@eutws1.win.tue.nl (Paul de Bra) (03/08/90)

In article <38281@cornell.UUCP> chandra@cs.cornell.edu (Tushar D Chandra) writes:
>Hi,
>
>I'm writing an application in which I need to keep a small process (1-2 pages)
>from getting swapped out.

SCO Xenix (i only looked at 2.2.1 for the 286) has a system call "plock"
which does this (when executed by root).

System V release 3.2 claims to be compatible with Xenix but fails in this
area as it does not have the plock call.

I'm afraid you are out of luck at this time, at least when looking at
the 'standard' unix versions. (BSD and SYSV).

Paul.
(debra@research.att.com)

bogatko@lzga.ATT.COM (George Bogatko) (03/09/90)

In article <1588@tuegate.tue.nl>, wsinpdb@eutws1.win.tue.nl (Paul de Bra) writes:
> In article <38281@cornell.UUCP> chandra@cs.cornell.edu (Tushar D Chandra) writes:
> 
> System V release 3.2 claims to be compatible with Xenix but fails in this
> area as it does not have the plock call.

Sorry...

uname
tm600b tm600b 3.2.1 3 3B2
cd /lib   
ar tv libc.a | grep plock
rw-r--r--  5079/  2003    314 May 25 17:44 1987 plock.o


GB

roe@sobeco.com (r.peterson) (03/12/90)

From article <38281@cornell.UUCP>, by chandra@thiazi.cs.cornell.edu (Tushar D Chandra):
> Hi,
> 
> I'm writing an application in which I need to keep a small process (1-2 pages)
> from getting swapped out.
> Does anyone out there know how to do this?

All versions of system V I've worked with support plock().  This may
do what you want.
-- 
"Norf gribble mitz der bork bork bork?"        Roe Peterson
"Lick spittle dwing dtz fritz slppp!"          roe@sobeco.com
	- Uncle Duke                           uunet!sobeco!roe

wsinpdb@eutws1.win.tue.nl (Paul de Bra) (03/12/90)

In article <1856@lzga.ATT.COM> bogatko@lzga.ATT.COM (George Bogatko) writes:
>> In article <38281@cornell.UUCP> chandra@cs.cornell.edu (Tushar D Chandra) writes:
>uname
>tm600b tm600b 3.2.1 3 3B2
>cd /lib   
>ar tv libc.a | grep plock
>rw-r--r--  5079/  2003    314 May 25 17:44 1987 plock.o
>

Oops, my goof. The call is there allright, and just to make sure I
checked the manual, and it's there too (no, this is not obvious)
and I wrote a small test program and verified that apart from being
there the system call actually works.

Guess I was still sleeping when I claimed that call wasn't there.

Just a word of warning: this call should not be used with large
processes, as this can easily hang the system (my first attempt caused
this). If you suddenly lock most of your memory (I locked 5Mbyte on an
8Mbyte system, which leaves about 1/2Mbyte available to other processes
in my case) the kernel is not able to keep the other processes going.
The whole system just locks up.

Paul.
(debra@research.att.com)

tim@Athena.UUCP (Tim Dawson) (03/17/90)

chandra@thiazi.cs.cornell.edu (Tushar D Chandra) writes:

>I'm writing an application in which I need to keep a small process (1-2 pages)
>from getting swapped out. ...                                      

AS per my references on SysVR3.5, the system call you are looking for is 
plock() thus:

#include <sys/lock.h>
int plock (op)
int op; 

Where op is:

PROCLOCK - lock test and data segments into memory (process lock)
TXTLOCK - leock text segments into memory (text lock)
DATLOCK - lock data segment into memory (data lock)
UNLOCK - remove locks.

This only works for superuser permissions

-- 
================================================================================
Tim Dawson (...!texsun!Athena!tim)  Motorola Computer Systems, Dallas, TX.
"The opinions expressed above do not relect those of my employer - often even I
cannot figure out what I am talking about."