3

When I type the command

top

The first row of the output is

29646 Usernam+  20   0 7041320 1.047g 105604 S  1267  0.6 256:11.86 MATLAB

As you can see, the CPU utilization is 1267%. That means, this process is using 13 CPU of the server. By the following command, I try to force this process to use only one CPU (The 30th CPU of server)

taskset -c -p 30 29646

However, I still see the CPU utilization of the process is about 1300%. Why taskset is not working properly?

Admia
  • 292

2 Answers2

2

Looks like an arguments misplacing. Try

taskset -c 30 -p <pid>
Yuri G.
  • 131
  • 2
    G: The command that you suggested does not work on my machine which is a Centos Linux. By using the "taskset" command in the way I previously indicated, I get a confirmation message from taskset indicating that the affinity of process is changed. However, "ps" command, I can see that taskset is not working properly and does have any effect on the CPU assignment. – Admia Nov 30 '15 at 02:40
2

Use

taskset -a -c -p 30 29646

From the man page:

-a, --all-tasks

Set or retrieve the CPU affinity of all the tasks (threads) for a given PID.

ederag
  • 350