Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Feb 2005 15:57:06 +0200
From:      Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua>
To:        Ashwin Chandra <ashcs@ucla.edu>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Kernel Monitor?
Message-ID:  <20050214135706.GA581@pm514-9.comsys.ntu-kpi.kiev.ua>
In-Reply-To: <000c01c5126f$354f81c0$58e243a4@ash>
References:  <000c01c5126f$354f81c0$58e243a4@ash>

next in thread | previous in thread | raw e-mail | index | archive | help
>   FOREACH_PROC_IN_SYSTEM(p) {
>     mtx_lock(&Giant);
>     PROC_LOCK(p);
>     printf("%d %d\n", (int)p->p_stats->p_ru.ru_isrss, (int)p->p_stats->p_ru.ru_idrss);
>     PROC_UNLOCK(p);
>     mtx_unlock(&Giant);
>   }

This code is incorrect, because you should get sx_slock(&allproc_lock)
before FOREACH_PROC_IN_SYSTEM and release sx_sunlock(&allproc_lock)
after this loop.  If you don't do this, then p in some iteration
will point to nothing.  Locking Giant, as I understand, here is not
required (even vefore FOREACH_...).



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