Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Aug 2012 19:31:17 -0700 (PDT)
From:      Daniel Rudy <dr2867@pacbell.net>
To:        davidxu@freebsd.org
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Enumerating sleeping threads
Message-ID:  <1343874677.32627.YahooMailClassic@web182206.mail.bf1.yahoo.com>
In-Reply-To: <5019E500.8060105@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--- On Wed, 8/1/12, David Xu <listlog2011@gmail.com> wrote:

From: David Xu <listlog2011@gmail.com>
Subject: Re: Enumerating sleeping threads
To: "Daniel Rudy" <dr2867@pacbell.net>
Cc: freebsd-hackers@freebsd.org
Date: Wednesday, August 1, 2012, 7:25 PM

On 2012/8/2 10:12, Daniel Rudy wrote:
> Hello,
>=20
> What is the best way to enumerate the sleeping threads via
> sleepqueue(9)?=A0 Furthermore, when enumerating the threads that are on
> the run queue, what locks are needed, if any?
sleepqueue hash bucket is private data structure in subr_sleepqueue.c, I th=
ink you
can not access it outside of the file.
One way to enumerate the sleeping threads is iterating all threads in the s=
ystem,
and check their states.=A0 proc.h contains two macros:
FOREACH_PROC_IN_SYSTEM
FOREACH_THREAD_IN_PROC

To access thread state, you should use thread lock,=A0 call thread_lock()
and thread_unlock(). thread lock is not fixed, it might be sleep-queue's sp=
inlock
or per-cpu runqueue lock, there even is a blocked spin-lock for intermediat=
e state
change.

> Thank you.
>=20


The problem is that I want to avoid using proc.h in this.=A0 I'm considerin=
g adding a function to subr_sleepqueue.c to export the data structures, or =
at least export a PID list.=A0 The reason why I am doing it this way is sec=
urity related.=A0=20




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1343874677.32627.YahooMailClassic>