Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I work on a Fedora server running on an Intel Xeon with 15 cores. Some users are running simulations that take up four of the cores, but others seem to be unused. Is there a way I can have a program run on the free cores instead of waiting for the used cores to be freed?

share|improve this question
1  
It should be automatic... did you find out that it is not? –  MariusMatutiae Nov 29 '13 at 16:19
1  
As Marius said, it should automatically do that (it would be absurd to queue processes on used cores when there are free ones available). If you are not seeing that to be the case, then you will need to find the problem and fix that. In the meantime, you can manually set the affinity for processes. –  Synetech Nov 29 '13 at 16:24
    
I found out it is not. I was running a process on one core and then someone started a process that takes 4 cores and my process was still on one of those four and the other process cosumed all the resources and mine was eternally slowed down. I am going to look for manually setting the affinity and see if that works, thank you. –  Zloy Smiertniy Nov 29 '13 at 16:27

1 Answer 1

up vote 1 down vote accepted

I found out it was matlab's fault. It did not respect my process. I ran it again after the other simulations were run and now it works on a separate core. Thanks to Synetech I found out anyway that the linux command taskset allows me to do what I need, in case I needed to do it manually.

$ taskset
Usage: taskset [options] [mask | cpu-list] [pid|cmd [args...]]

Options:
 -p, --pid               operate on existing given pid
 -c, --cpu-list          display and specify cpus in list format
 -h, --help              display this help
 -V, --version           output version information

The default behavior is to run a new command:
    taskset 03 sshd -b 1024
You can retrieve the mask of an existing task:
    taskset -p 700
Or set it:
    taskset -p 03 700
List format uses a comma-separated list instead of a mask:
    taskset -pc 0,3,7-11 700
Ranges in list format can take a stride argument:
    e.g. 0-31:2 is equivalent to mask 0x55555555

For more information see taskset(1).
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.