Skip to contentSkip to conversation

looking for a function

DISCUSSION Xu Yang 5 participants 8 messages Sep 16, 2008

lore
Share & tools
lore

Xu Yang

author
#0 lore raw

Hi guys,

I am looking for a function that can show me the current thread is running on which cpu.

e.g I am using pthread to write a multithreaded program, in each thread I would like to insert such kind of function so that I can know on which cpu this thread is running on.

which function should be used?

thanks for the help!!

best regards,

Yang

#1 lore raw

Hi!

Quoted 8 lines · Xu Yang

Hi guys,

I am looking for a function that can show me the current thread is running on which cpu.

e.g I am using pthread to write a multithreaded program, in each thread I would like to insert such kind of function so that I can know on which cpu this thread is running on.

That doesn't make much sense as the same thread can run on a different CPU after each scheduling decision. And - as it is in userspace - scheduling can happen before any assembler op.

Bernd

Signature · 3 lines
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services
author
#2 lore raw

Hi Bernd,

thanks for you reply.

yes, I know the thread migrates all the time, this is exactly what I would like to observe. I would like to learn about the thread migration of some specific scheduling algorithm. so ....

any idea about the function?

Best regards,

Yang

2008/9/16, Bernd Petrovitsch <[email protected]>:

Quoted 24 lines

Hi!

Quoted 8 lines · Xu Yang

Hi guys,

I am looking for a function that can show me the current thread is running on which cpu.

e.g I am using pthread to write a multithreaded program, in each thread I would like to insert such kind of function so that I can know on which cpu this thread is running on.

That doesn't make much sense as the same thread can run on a different CPU after each scheduling decision. And - as it is in userspace - scheduling can happen before any assembler op.

Bernd
--
Firmix Software GmbH http://www.firmix.at/
mobil: +43 664 4416156 fax: +43 1 7890849-55
Embedded Linux Development and Services

#3 lore raw
Quoted 9 lines · On Tue, 16 Sep 2008 16:11:10 +0200 "Xu Yang" <[email protected]> wrote:

Hi Bernd,

thanks for you reply.

yes, I know the thread migrates all the time, this is exactly what I would like to observe. I would like to learn about the thread migration of some specific scheduling algorithm. so ....

any idea about the function?

the getcpu() system call will do what you want.

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
author
#4 lore raw

Hi Arjan,

thanks,
I will try that!

Best regards,

Yang

2008/9/16, Arjan van de Ven <[email protected]>:

Quoted 22 lines
Quoted 9 lines · On Tue, 16 Sep 2008 16:11:10 +0200 "Xu Yang" <[email protected]> wrote:

Hi Bernd,

thanks for you reply.

yes, I know the thread migrates all the time, this is exactly what I would like to observe. I would like to learn about the thread migration of some specific scheduling algorithm. so ....

any idea about the function?

the getcpu() system call will do what you want.

--
Arjan van de Ven Intel Open Source Technology Centre
For development, discussion and tips for power savings, visit http://www.lesswatts.org

#5 lore raw
In reply to Xu Yang

2008/9/16 Xu Yang <[email protected]>:

Quoted 10 lines

Hi Bernd,

thanks for you reply.

yes, I know the thread migrates all the time, this is exactly what I would like to observe. I would like to learn about the thread migration of some specific scheduling algorithm. so ....

any idea about the function?

And perhaps you should have a look at the sched_switch tracer which will log for you the different context switches.

Regards,

Frederic.

author
#6 lore raw

Hi Frederic,

thank you very much!
this is very useful for me. :-)

Best regards,

Yang

2008/9/16, Frédéric Weisbecker <[email protected]>:

Quoted 19 lines

2008/9/16 Xu Yang <[email protected]>:

Quoted 10 lines

Hi Bernd,

thanks for you reply.

yes, I know the thread migrates all the time, this is exactly what I would like to observe. I would like to learn about the thread migration of some specific scheduling algorithm. so ....

any idea about the function?

And perhaps you should have a look at the sched_switch tracer which will log for you the different context switches.

Regards,

Frederic.

#7 lore raw
In reply to Xu Yang
Quoted 8 lines · Xu Yang

Hi Bernd,

thanks for you reply.

yes, I know the thread migrates all the time, this is exactly what I would like to observe. I would like to learn about the thread migration of some specific scheduling algorithm. so ....

Quoted 5 lines

any idea about the function?

Best regards,

Yang

getcpu() should do what you want.

-- Chris

Quoted 28 lines

2008/9/16, Bernd Petrovitsch <[email protected]>:

Quoted 14 lines

Hi!

Quoted 7 lines · Xu Yang

Hi guys,

I am looking for a function that can show me the current thread is running on which cpu.
e.g I am using pthread to write a multithreaded program, in each thread I would like to insert such kind of function so that I can know on which cpu this thread is running on.

That doesn't make much sense as the same thread can run on a different CPU after each scheduling decision. And - as it is in userspace - scheduling can happen before any assembler op.

Quoted 8 lines

Bernd
--
Firmix Software GmbH http://www.firmix.at/
mobil: +43 664 4416156 fax: +43 1 7890849-55
Embedded Linux Development and Services

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/