Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!mailrus!umix!umich!mibte!gamma!ulysses!thumper!faline!bellcore!tness7!ninja!pollux!dalsqnt!rpp386!jfh From: jfh@rpp386.UUCP (John F. Haugh II) Newsgroups: comp.unix.microport Subject: Re: Why are there two swapper processes? Message-ID: <637@rpp386.UUCP> Date: 5 Apr 88 06:32:43 GMT References: <352@mancol.UUCP> <17656@watmath.waterloo.edu> Reply-To: jfh@rpp386.UUCP (The Beach Bum) Organization: Big "D" Home for Wayward Hackers Lines: 36 In article <17656@watmath.waterloo.edu> rwwetmore@watmath.waterloo.edu (Ross Wetmore) writes: >In article <352@mancol.UUCP> samperi@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@rpp386 | | FOR RENT | DATA: +1 214 250-6272, login: anonuucp | +----------+