sticky bits ?
David Sherman
dave at lsuc.UUCP
Tue Feb 19 12:11:56 AEST 1985
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
More information about the Comp.unix.wizards
mailing list