From: Peter Boyle <pboyle@holyrood.ed.ac.uk>
Subject: Re: SMP processor identification
Date: 2000/05/08 [thread overview]
Message-ID: <Pine.GSO.4.10.10005081803540.14800-100000@holyrood.ed.ac.uk> (raw)
In-Reply-To: 3916C2BA.9754D1E8@ife.ee.ethz.ch
On Mon, 8 May 2000, Alex Rhomberg wrote:
> Does anybody know a way how I can identify on which processor a thread
> is currently running on UP2000?
>
> Thanks
> - Alex
>
>
Hi,
had a quick look in the fs/proc kernel source and there is a routine
which puts a per processor cpu time into a buffer, so I am sure that
somewhere in /proc/pid the per processor cpu time usage is available.
Watching that file to see which cpu time is increasing will be available
(I am running a single processor kernal, so the #ifdef stops me seeing
it in my /proc )
HTH,
Peter
#ifdef __SMP__
static int get_pidcpu(int pid, char * buffer)
{
struct task_struct * tsk = current ;
int i, len;
read_lock(&tasklist_lock);
if (pid != tsk->pid)
tsk = find_task_by_pid(pid);
read_unlock(&tasklist_lock); /* FIXME!! This should be done
after the
last use */
if (tsk == NULL)
return 0;
len = sprintf(buffer,
"cpu %lu %lu\n",
tsk->times.tms_utime,
tsk->times.tms_stime);
for (i = 0 ; i < smp_num_cpus; i++)
len += sprintf(buffer + len, "cpu%d %lu %lu\n",
i,
tsk->per_cpu_utime[cpu_logical_map(i)],
tsk->per_cpu_stime[cpu_logical_map(i)]);
return len;
}
Peter Boyle pboyle@physics.gla.ac.uk
prev parent reply other threads:[~2000-05-08 4:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-05-08 4:00 SMP processor identification Alex Rhomberg
2000-05-08 4:00 ` Peter Boyle [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox