LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 05-24-2009, 09:47 AM   #1
wwrrrrww
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, 07:26 PM   #2
ouain
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 http://codesearch.google.com/ 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.
 
  


Reply


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 05:32 PM
SMP system - use a single CPU during boot bromanescu Programming 4 10-18-2008 05:29 PM
SMP system :how to know which CPU a process belong to ? hhshr825 Linux - Newbie 4 01-11-2008 03:04 AM
is SMP really using every cpu? deadlinx Linux - Kernel 3 06-26-2006 09:19 AM
SMP and 2nd cpu FeeBLe Linux - Hardware 4 05-04-2005 12:57 PM


All times are GMT -5. The time now is 12:51 AM.

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