[comp.unix.questions] Question about paging and swapping

ruba@biophys.UUCP (Rudolf Baumann) (06/09/89)

I would like a clear description about the difference of paging and 
swapping and which of both has more influence on the performance of
a system. I could yet not found an clear answer to this question 
neither in the manuals nor in a book. 
Thank you
	ruedi

-----------------------------------------------------------------------------
Rudolf E. Baumann                                    ruba@biophys.zir.ethz.ch
Institut fuer Molekularbiologie & Biophysik          ruba@biophys.uucp
ETH Hoenggerberg (HPM G6)                            MOLEKULA@CZHETH5A.bitnet
CH-8093 Zuerich/Switzerland                          Tel. ++41 1 377 33 97
-----------------------------------------------------------------------------

gwyn@smoke.BRL.MIL (Doug Gwyn) (06/11/89)

In article <381@biophys.UUCP> ruba@biophys.UUCP (Rudolf Baumann) writes:
>I would like a clear description about the difference of paging and 
>swapping and which of both has more influence on the performance of
>a system.

There are a lot of variations, but the basic distinction is that
an entire process space is swapped out, while only a segment of a
process is paged out to backing store.  Other things being equal
(which they usually aren't), paging evidently involves less work
for the operating system and consequently should be more efficient.

In actual practice, if the job mix demands much more main memory
than is actually available, simplistic implementations of both
swapping and paging are likely to lead to severe thrashing and
consequent overall system inefficiency.  Additional cleverness is
required in the system memory allocation and scheduling algorithms
to overcome this tendency.

It's a bit strange that you couldn't find a discussion of this
in an operating system design book; I would have thought that it's
a standard topic.

hart@nova.laic.uucp (Howard C. Hart) (06/14/89)

In article <381@biophys.UUCP> ruba@biophys.UUCP (Rudolf Baumann) writes:
>I would like a clear description about the difference of paging and 
>swapping and which of both has more influence on the performance of
>a system. I could yet not found an clear answer to this question 

As an instructor of mine very aptly put it, you're the manager of a 
company, trying to get some work done (the CPU), but all the workers
(processess) keep interrupting with their inputs/tasks that just have
to be done right away. You can try to respond to each of them one
subtask at a time (a page), then interrupt that subtask to service
another workers subtask (another page) and so on, or you can be more
efficient and service a whole worker's task at a time (swap many pages
in sequence) without allowing interruptions by other workers. This
avoids the overhead of too many changes of subject (context switches)
brought on by answering a very small portion of each worker's questions
, then moving on to the other. 
Please note, this analogy has holes in it big enough to drive a tank
through, but you did ask for a clear description. As for relative
performance, I'll give you the party line...it depends on the
size of the application and other factors. The above explanation should
give you a first cut at which method shows higher performance. Swapping
is usually better, but if you could fit many processes on one page each,
the inherent overhead in swapping would make it slower than paging.


Howard C. Hart                  UUCP:{sun!sunncal,pyramid}!leadsv!laic!nova!hart
Lockheed Missiles and Space Co.
Orgn 59-53, Bldg 593            Ph: (408) 743-2253 or -7353
Sunnyvale, CA 94086

dwc@cbnewsh.ATT.COM (Malaclypse the Elder) (06/15/89)

In article <584@laic.UUCP>, hart@nova.laic.uucp (Howard C. Hart) writes:
> In article <381@biophys.UUCP> ruba@biophys.UUCP (Rudolf Baumann) writes:
> >I would like a clear description about the difference of paging and 
> >swapping and which of both has more influence on the performance of
> >a system. I could yet not found an clear answer to this question 
> 
> AN ANALOGY WAS GIVEN HERE

i have my own analogy that i have been using and it gives a good
feel for the tradeoffs involved.  imagine a copy machine with a number
of users who must copy memos.  and suppose this copy machine has
one of those automatic feeders.  then the difference between swapping
and paging is akin to allowing the users to use the feeder (swapping)
or limiting them to one sheet at a time and then getting on the end
of the line (paging).

you might say that it would seem that swapping is always preferable
but note that the paging scheme is "fairer".  and more importantly,
what if the purpose of the copying were to copy on a few (maybe every
Nth) pages out of each memo?  then the analogy becomes forcing them
to use the sheet feeder for their entire document (swapping) or allowing
them to do a single sheet, the one they really need, at a time (paging).

i think this captures the essence of the tradeoff.  of course the obvious
solution is to allow the users to use the feeder when it is prudent to
do so, subject to some limits (in our company there is a sign at the public
service machines that says "please limit yourself to 20 copies of 20
originals"), and to do single sheet at a time when they think it wise.
thus most systems have some form of both paging and swapping although
i feel that there is usually too much reliance on the paging mechanism
to manage memory resources (extend the analogy further to include requiring
the users to both get to the copy glass AND obtain plain paper to copy on
(ie obtain physical memory), etc. and imagine the lines at the copy machine)

danny chen
att!hocus!dwc