[mod.unix] Unix Technical Discussions V1 #8

unix@cbosgd.UUCP (03/11/85)

From: Ron Heiby (The Moderator) <unix-request@cbosgd.UUCP>


Unix Technical Discussions     Sun, 10 Mar 1985    Volume 1 : Issue 8

Today's topics:
			Sticky Bits  (4)
----------------------------------------------------------------------

Date: 14 Feb 85 00:37:15 GMT
From: chris@byucsa.UUCP (Chris J. Grevstad)
Subject: sticky bits ?

Can someone out there tell me about sticky bits?
We have here a fairly large program (a machine simulator) that many
students are required to run.  We also have have a couple of large
statisitcs programs with the characteristic of causing large
amounts of swapping.
Are these appropriate instances in which on should use the sticky bit?
And what are the implications?
-- 
Chris Grevstad
{ihnp4,noao,mcnc,utah-cs}!arizona!byucsa!chris

------------------------------

Date: 15 Feb 85 16:51:57 GMT
From: fred@mot.UUCP (Fred Christiansen)
Subject: Re: sticky bits ?

(our environment:  System V Release 2 on VAX and 68000-based systems)

Setting the sticky bit causes the loadable image of a program to go
to swap on its first invocation and stay there, even after the program
terminates execution.  This speeds up the loading of subsequent invocations
of the same program.  This is handy for commonly invoked programs.
	While benign, it is of little use to set the sticky bit on a program
that will be nearly continuously in use (such as init(1m), getty(1), or sh(1))
since, by the nature of its usage, it is normally in this "state" anyhow.
	The recommendation of the SysV Administrator's manual is to run
the system activity package and observe the 20 or so most commonly invoked
programs, then set the sticky bit on these.  The caveat here, tho, is to
scale that number (20) up or down depending on the amount of swap space
allocated.  (We had one panicking customer call for help when he kept
running out of swap space.  Turns out he was filling up his swap space
by having the sticky bit set on too many programs.)
-- 
Fred Christiansen, Networking Software, Motorola Microsystems, Tempe, AZ  85282
{allegra,ihnp4}!sftig!mot!fred         {ihnp4,seismo}!ut-sally!oakhill!mot!fred
{ihnp4,amdahl}!drivax!mot!fred                   ucbvax!arizona!asuvax!mot!fred

------------------------------

Date: 19 Feb 85 02:11:56 GMT
From: dave@lsuc.UUCP (David Sherman)
Subject: Re: sticky bits ?

OK, time for tutorial (well, a monologue) on shared-text and
sticky-bitting.

Every process takes up space in memory. Part of this space is
"text" and part is "data". ("Text" is, roughly, the machine
instructions, and "data" is the space for user variables.)

If you have processes which many users run at the same time (e.g.,
a shell or editor), then you can have all users run out of the
same text space and avoid using up lots of memory, by using the
"shared-text" feature of UNIX. To get this, compile with "cc -n".
To look for it, run file(1) and look for the word "pure", as in
"pure executable". To find out the relative text and data sizes
of your executable, run size(1).

The number of shared-text programs which can be running at one
time is limited by the system, since it needs to check all
processes against a table when they are started up. This is
the system parameter NTEXT. If you run out, you'll get an "Out
of text" on the console, but the system should not crash.

Once you're running shared-text, there's a further optimization
you can do. That is sticky-bitting. You do it by turning on the
01000 bit with chmod (in plainer language, with "chmod 1755 file").
You see it as "rwxr-xr-xt" (V6) or "rwxr-xr-t" (V7) with ls -l.
The effect of sticky-bitting is described quite well in chmod(2):
	"  mode 1000 prevents the system from abandoning
     the swap-space image of the program-text portion of the file
     when its last user	terminates.  Thus when the next	user of
     the file executes it, the text need not be	read from the
     file system but can simply	be swapped in, saving time. "

The usefulness of these features depends in part on your application.
If you have lots and lots of memory, they won't make too much
difference. In our application, we can have 30 students at a time
running the same 100K program on a machine with only 1 Meg of
memory, so it's pretty important.

The above description applies to V6 and V7, and to later derivatives
as far as I know. If you found it useful, please let me know.

Dave Sherman
-- 
{utzoo pesnta nrcaero utcs}!lsuc!dave
{allegra decvax ihnp4 linus}!utcsri!lsuc!dave

------------------------------

Date: 16 Feb 85 20:18:05 GMT
From: chris@byucsa.UUCP (Chris J. Grevstad)
Subject: sticky bits? (rephrasing)

Thanks for the replies about sticky bits, but I fogot to indicate
which *unix* we are running.  It is 4.2BSD on a Vax 11/750.

It was indicated that under 4.*BSD the sticky bit has no effect.
Any different responses?
-- 
Chris Grevstad
{ihnp4,noao,mcnc,utah-cs}!arizona!byucsa!chris

------------------------------

End of Unix Technical Discussions
*****************************
-- 
Ronald W. Heiby / ihnp4!{wnuxa!heiby|wnuxb!netnews}
AT&T Information Systems, Inc.
Lisle, IL  (CU-D21)