From owner-freebsd-hackers@FreeBSD.ORG Sat Apr 24 00:32:03 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C6B89106564A for ; Sat, 24 Apr 2010 00:32:03 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.153]) by mx1.freebsd.org (Postfix) with ESMTP id 5597C8FC08 for ; Sat, 24 Apr 2010 00:32:02 +0000 (UTC) Received: by fg-out-1718.google.com with SMTP id 22so416250fge.13 for ; Fri, 23 Apr 2010 17:32:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=zjZ7iM2F2qh21PlWphTP7vGS035LGPjZ/+wvrUOy0Nw=; b=Co0NDW3flFBCHa/sNCccLV6AOuGd9RqSbY6BSLO1GpVACN+WaRYHQbK3IT+XE3fGk7 jv9C/9JdcqxVWlVSx5G7pwzdIku3aHdWWnTtPsvMdWDKa1v8QqNFaSU1Nnw0N9CYHPvJ u8/b1wqOkl4yeb0cWuouGvg0f/dYlmF6OTyTA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=lipy/qtGK9RNl00iWo/7+cAC9ZhxyX+DzDaw6pkNCiS7yo6IKBHV4hZauhbksx1ClI YWhpGU6O4TMXlqYSzx1TJmvBz40erHIkWLv4AoaCIlkUDbYstf9MksqB/Rm+kWGDiKS/ 07ELuYS4oR3Zb16ZKWLx57xCdEgmjAKSfnIPY= MIME-Version: 1.0 Received: by 10.239.191.194 with SMTP id c2mr66555hbi.169.1272069122101; Fri, 23 Apr 2010 17:32:02 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.239.180.194 with HTTP; Fri, 23 Apr 2010 17:32:02 -0700 (PDT) In-Reply-To: <06D5F9F6F655AD4C92E28B662F7F853E039E34E1@seaxch09.desktop.isilon.com> References: <06D5F9F6F655AD4C92E28B662F7F853E039E34E1@seaxch09.desktop.isilon.com> Date: Sat, 24 Apr 2010 02:32:02 +0200 X-Google-Sender-Auth: ca03228fc46fa44f Message-ID: From: Attilio Rao To: Matthew Fleming Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: FreeBSD-Hackers Subject: Re: idle threads X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Apr 2010 00:32:03 -0000 2010/4/24 Matthew Fleming : > I'm looking at kern_idle.c in stable/7 and I don't quite follow how idle > threads work. =C2=A0The kthread_create(9) call does not pass in a functio= n > pointer, so what code does a processor run when there is no other > runnable thread? In STABLE_7: ... #ifdef SMP SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { error =3D kthread_create(sched_idletd, NULL, &p, RFSTOPPED | RFHIGHPID, 0, "idle: cpu%d", pc->pc_cpuid); pc->pc_idlethread =3D FIRST_THREAD_IN_PROC(p); #else error =3D kthread_create(sched_idletd, NULL, &p, RFSTOPPED | RFHIGHPID, 0, "idle"); PCPU_SET(idlethread, FIRST_THREAD_IN_PROC(p)); #endif ... then they rightly passes sched_idletd(). Any scheduler may define its own version of sched_idletd(). NULL is just the argument passed that is not meaningful. Or maybe I'm not understanding your question? Attilio --=20 Peace can only be achieved by understanding - A. Einstein