From owner-freebsd-hackers@FreeBSD.ORG Sat Mar 21 22:02:52 2015 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 591CDE99 for ; Sat, 21 Mar 2015 22:02:52 +0000 (UTC) Received: from mail-we0-x230.google.com (mail-we0-x230.google.com [IPv6:2a00:1450:400c:c03::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DB61DF5 for ; Sat, 21 Mar 2015 22:02:51 +0000 (UTC) Received: by wetk59 with SMTP id k59so108261208wet.3 for ; Sat, 21 Mar 2015 15:02:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=uJuKIMBNMMlvIhl/2pTbOHOcvYnvy0JJZTb6H9oRbac=; b=VJYNPUZHM8zBeG/LL3cVX15voLWnlsQh9qLC1ThjM+8p0WMWGEQWXK8pddKaDxMJLx yjytigjBHhvkiNo/ZYDHERSFA5wmzRZxvo17J52aoiCEUd5WbOePklApd8zCeskpCqw0 GOoEhGU7SNyrhFY+qdXanu+ZxDnUHmEUC1tSRyfbXPk5ShniXyOeZDbhSx1kdAXlnB0R FrjFRSzLl0Gq2+3QLDA27Yb2kP4OpVCXscnrZRhIQXp68lWds2OJ6ML++cKa+FeXDYES cm2NSR+mlGrAPVLukyZGWq57VINfiR7BtBjexoHQeqgsD3hz37LIkKaf8Yi/R+LJmIEf kj3Q== X-Received: by 10.180.103.170 with SMTP id fx10mr2100321wib.57.1426975370283; Sat, 21 Mar 2015 15:02:50 -0700 (PDT) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by mx.google.com with ESMTPSA id uo6sm12285944wjc.49.2015.03.21.15.02.48 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 21 Mar 2015 15:02:49 -0700 (PDT) Date: Sat, 21 Mar 2015 23:02:46 +0100 From: Mateusz Guzik To: Yue Chen Subject: Re: How to traverse kernel threads? Message-ID: <20150321220246.GE14650@dft-labs.eu> Mail-Followup-To: Mateusz Guzik , Yue Chen , "freebsd-hackers@freebsd.org" References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: "freebsd-hackers@freebsd.org" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Mar 2015 22:02:52 -0000 On Sat, Mar 21, 2015 at 05:54:24PM -0400, Yue Chen wrote: > Dear all, > > Is there an easy way to traverse all the kernel threads (including > modules') in a FreeBSD kernel module? > The resulting structure would be `` struct thread * ''. > Well if you read kthread_add you can see you just need to traverse threads linked into proc0. Chances are you also want to traverse kernel process (see kproc_create). The real question though is what are you trying to achieve. -- Mateusz Guzik