From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111c93,f41c0f93240a2a2f X-Google-Attributes: gid111c93,public From: Peter Boyle Subject: Re: SMP processor identification Date: 2000/05/08 Message-ID: #1/1 X-Deja-AN: 620723948 References: <3916C2BA.9754D1E8@ife.ee.ethz.ch> Content-Type: TEXT/PLAIN; charset=US-ASCII X-Complaints-To: usenet@scotsman.ed.ac.uk X-Trace: scotsman.ed.ac.uk 957805625 4373 129.215.16.14 (8 May 2000 17:07:05 GMT) Organization: Edinburgh University Mime-Version: 1.0 NNTP-Posting-Date: 8 May 2000 17:07:05 GMT Newsgroups: comp.os.linux.alpha 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