Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to get/set the current processor on an SMP system?

2 views
Skip to first unread message

JF Larvoire

unread,
Feb 27, 2003, 12:33:55 PM2/27/03
to
Hello,

I found references on the Web to a "pset" package, with a sysmp() function
that seems to do what I need.
Unfortunately, this package in not included in my distribution, and the web
sites are 4-years old.
- Is pset still maintained, and if so where can it be found now?
- Is there any other portable way to get/set the processor a thread is
running on?
Thanks,

Jean-François


Kasper Dupont

unread,
Feb 27, 2003, 3:03:33 PM2/27/03
to
JF Larvoire wrote:
>
> - Is there any other portable way to get/set the processor a thread is
> running on?

I doubt you will find anything portable. On Linux you can get the
current processor number by reading /proc/self/stat. The field is
actually the current CPU of the process, or the last CPU it was
running on in case it is currently sleeping. However since the
current process is running, you know that it is not sleeping.

You should keep in mind, that this value is only guaranteed to be
correct the moment you read it. As soon as you have finished
parsing the file, you could already have been moved to another CPU.

I don't know why you want to force a process onto a specific
processor. The kernel will try to do find the optimal choice of
processor for the processes. However in most recent 2.5 kernels
there is a systemcall to specify a mask of allowed CPUs for the
process.

--
Kasper Dupont -- der bruger for meget tid på usenet.
For sending spam use mailto:aaa...@daimi.au.dk
for(_=52;_;(_%5)||(_/=5),(_%5)&&(_-=2))putchar(_);

Christopher Browne

unread,
Feb 27, 2003, 4:52:19 PM2/27/03
to
Quoth "JF Larvoire" <jean-francois.larvoire@remove_this.free.fr>:

In practice, it has proven preferable to let the kernel shift tasks to
whatever processor it sees fit to use. After all, it will have a
better idea than any other system component whether it's busy or not.

It is quite likely that what you're trying to accomplish is something
you shouldn't bother trying to accomplish.
--
(reverse (concatenate 'string "ac.notelrac.teneerf@" "454aa"))
http://cbbrowne.com/info/finances.html
Shin: A device for finding furniture in the dark.

0 new messages