7

In order to do quality assurance in a critical multicore (8) workstation, I want to run the same code in different processors but not in parallel or concurrently.

I need to run it 8 times, one run for each processor.

What I don't know is how to select the processor I want.

How can this be accomplished in Python?

2
  • 5
    I think you ought to include the operating system(s) you are targeting. Scheduling on CPUs is out of Python's purview for the most part ( neglecting calling out to the OS to do the scheduling of course ). Commented Jul 22, 2009 at 16:20
  • It's on Linux Fedora. Thanks for the remark! Commented Jul 23, 2009 at 17:54

2 Answers 2

5

In Linux with schedutils, I believe you'd use taskset -c X python foo.py to run that specific Python process on CPU X (exactly how you identify your CPUs may vary, but I believe numbers such as 1, 2, 3, ... should work anywhere). I'm sure Windows, BSD versions, etc, have similar commands to support direct processor assignment, but I don't know them.

Sign up to request clarification or add additional context in comments.

Comments

3

Which process goes on which core is normaly decided by your OS. On linux there is taskset from the schedutils package to explicitly run a program on a processor.

Python 2.6 has a multiprocessing module that takes python functions and runs them in seperate processes, probably moving each new process to a different core.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.