Why are there two swapper processes?

John F. Haugh II jfh at rpp386.UUCP
Tue Apr 5 16:32:43 AEST 1988


In article <17656 at watmath.waterloo.edu> rwwetmore at watmath.waterloo.edu (Ross Wetmore) writes:
>In article <352 at mancol.UUCP> samperi at mancol.UUCP (Dominick Samperi) writes:
>>     UID   PID  PPID  C    STIME TTY      TIME COMMAND
>>    root     0     0 40 02:48:46 ?       300:59 swapper
>>    root     1     0  0 02:48:46 ?        0:25 [ init ]
>>    root     0     0  0 02:48:46 ?        0:55 swapper
>
>  Something I always puzzled over was why there were always 2 swapper
>processes listed by ps, and why one is normally not used. Since this is
>apparently not a local phenomenon, maybe someone can shed light on this
>piece of trivia?

the first swapper runs when the operating system is idle.  if the clock
interupt catches the swapper looping in an idle state, the swapper gets
billed for that one tick.  so far as i know, this has been true since
system iii days.  i don't believe is was the case in version 7.  to test
this, next time you single user your system, do this.

# ps -fp 0 ; sleep 60 ; ps -fp 0

while yield a one minute change in the swapper's cpu time.

the second `swapper' has more to do with swapping and is only run when
pages are swapped in (or is it out?).  the `swapper' message is produced
by ps, rather than getting the command name from u_comm, which is the
standard idiom (or else searching for it on the process stack).  if
p_flag & SSYS is true, then ps names the process `swapper'  i believe
the pid is zero to keep kill from getting more complex.  rather than
having to make an exception for pid = 2, someone decided both scheduling
processes would be pid = 0.

- john.
-- 
John F. Haugh II, in the bedroom.      | +----------+
UUCP:	...!ihnp4!ninja!rpp386!jfh     | | SPACE    |
DOMAIN:	jfh at rpp386                     | | FOR RENT |
DATA: +1 214 250-6272, login: anonuucp | +----------+



More information about the Comp.unix.microport mailing list