Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-24-2009, 08:47 AM   #1
LQ Newbie
Registered: May 2009
Posts: 1

Rep: Reputation: 0
Is there any way to get cpu index on a smp system ?

i known that there exist a function call nemed "raw_smp_cpu_id" ,how do i call it in a linux application ?can any one give me a hand ?
Old 05-31-2009, 06:26 PM   #2
LQ Newbie
Registered: May 2009
Distribution: debian
Posts: 12

Rep: Reputation: 0
Warning: unless you specificly requested to run on a restricted number of cpus, there is now guarantee at all you will always run on the same cpu. I looked for the call you mention on and no one seems to use it. Then, I'm pretty sure it doesn't exist. However, a call that looks pretty similar to what you want is getcpu.

Additionaly, you can force your process to run on a given cpu or on some of the cpus with sched_setaffinity. You can also know the set of cpus you can run on with sched_getaffinity.

The three above calls are defined in sched.h.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
pthread_mutex_lock/unlock SMP and CPU cache coherence on core2 SMP sergxm Linux - Kernel 0 01-27-2009 04:32 PM
SMP system - use a single CPU during boot bromanescu Programming 4 10-18-2008 04:29 PM
SMP system :how to know which CPU a process belong to ? hhshr825 Linux - Newbie 4 01-11-2008 02:04 AM
is SMP really using every cpu? deadlinx Linux - Kernel 3 06-26-2006 08:19 AM
SMP and 2nd cpu FeeBLe Linux - Hardware 4 05-04-2005 11:57 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:40 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration