From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,64cad96cadb902e1,start X-Google-Attributes: gidfee84,public X-Google-Thread: 10650a,f5052e99c4d2205f X-Google-Attributes: gid10650a,public X-Google-Thread: 11035d,f5052e99c4d2205f X-Google-Attributes: gid11035d,public From: "T. Srikanth" Subject: Re: Why Restart in Wakeup? Date: 1998/05/29 Message-ID: <356EEA18.DCA42C85@cisco.com>#1/1 X-Deja-AN: 357688316 Content-Transfer-Encoding: 7bit References: <356DABF9.91A235BD@cisco.com> <6kkvl7$1rh$1@reader1.reader.news.ozemail.net> <6km98m$2sc$1@gte1.gte.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: cisco Systems Newsgroups: comp.unix.internals,comp.unix.osf.osf1,comp.unix.solaris > > I'd be more inclined to ask why bother with the 'else continue' > > on lines 14 and 15. Looks redundant to me. > > > > -am > > Indeed, my kernel (FreeBSD) does not have the else, continue clause. As > to the original question, sleeping processes are put on one of several > linked lists (depending on wchan). If the process is swapped, wakeup is > called recursively to wake up process 0 (the swapper). This has the > potential to invalidate the ``next process on list'' pointer of the > sleeping process, so the scan of the list is begun again at the > beginning. > > Jon Snader This sure is the hint! Swapper sleeps on the address of its proc table structure. There cannot possibly be many other processes on this private event identifier referred to as &proc0 in NetBSD. Since the kernel may maintain hashed lists of the processes in sleep, wakeup of the kernel process swapper can lead to modification of forward and backward pointers in the sleep queue. Since wakeup means "putting the process back on the run list", this could be expensive and does not guarantee the woken-up processes will really run. They may again be put back to sleep on "the survival of the luckiest process" basis. - srikanth