From owner-freebsd-hackers Tue Jun 6 7:55:58 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by hub.freebsd.org (Postfix) with ESMTP id B1E0C37B514 for ; Tue, 6 Jun 2000 07:55:52 -0700 (PDT) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.9.3/8.9.1) id HAA93643; Tue, 6 Jun 2000 07:55:40 -0700 (PDT) (envelope-from dillon) Date: Tue, 6 Jun 2000 07:55:40 -0700 (PDT) From: Matthew Dillon Message-Id: <200006061455.HAA93643@apollo.backplane.com> To: "G.B.Naidu" Cc: Duncan Barclay , freebsd-hackers@FreeBSD.ORG Subject: Re: wakeup() question References: Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG :Hi, : :For me it appears that the process should be marked as runnable. But I am :not sure. : :thanks :--gb : :On Mon, 5 Jun 2000, Duncan Barclay wrote: : :> Hi all :> :> Does wakeup() ever cause a sleeping processes to run before the wakeup() :> function returns, or does it just mark the process as running? :> :> Duncan :> :> Duncan Barclay | God smiles upon the little children, wakeup() is callable from an interrupt so it doesn't synchronously switch to the newly woken up process. However, it does call need_resched() (see i386/include/cpu.h) which queues the astpending software interrupt to handle switching to the new process. The astpending software interrupt is processed just before the system goes from a supervisor context to a user context (whether it is returning from an interrupt or returning from a system call). Thus if you have an interrupt which calls wakeup() which results in the new processes getting rescheduled, the system will switch to a new (may or may not be the one you woke up) process when the interrupt handler returns. So, in general, the newly ready process will not start running until after whoever called wakeup() tries to return to user mode. *BUT*, on an SMP box we have a different story. On an SMP box another cpu may pick-up the new process and start running it the instant wakeup() puts it on the run queue. This pickup is currently predicated on whether the context doing the waking up is holding the MP lock or not. You can't depend on that, though. The scheduler will almost certainly get its own separate locking thingy for the new SMP design. -Matt To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message