Thread: Run code on specific CPU?

  1. #1
    Registered User
    Join Date
    Mar 2008

    Run code on specific CPU?


    is there a way to select the CPU on which a program will run from within this program?
    I'm looking for a way to run some test with the CPUID instruction on every logical CPU in the system, but the CPU that runs my program will be "randomly" selected by the scheduler...


  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    If you're looking for some way to execute a program as if it were running on a different processor, then the only way I can think of to do that is to use emulation of some sort. Emulation is slow and a often pain to set up. Why do you need to do this?

    /proc/cpuinfo seems to be the easiest way . . . .

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    Yes, Intel processor supports selecting one specific core of available in the system. I do not remeber exactly how it is done - You probably need to look on the intel's site...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  2. Code compiles but doesn't run
    By dbyte in forum C Programming
    Replies: 5
    Last Post: 07-22-2003, 08:25 PM
  3. << !! Posting Code? Read this First !! >>
    By kermi3 in forum Linux Programming
    Replies: 0
    Last Post: 10-14-2002, 01:30 PM
  4. << !! Posting Code? Read this First !! >>
    By biosx in forum C++ Programming
    Replies: 1
    Last Post: 03-20-2002, 12:51 PM