2

This question already has an answer here:

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?

marked as duplicate by Archemar, roaima, mdpc, G-Man, Jesse_b Feb 6 '18 at 13:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

migrated from stackoverflow.com Nov 29 '15 at 9:58

This question came from our site for professional and enthusiast programmers.

  • 3
    Isn't this a problem for Unix & Linux? – Nathan Tuggy Nov 29 '15 at 1:46
  • The operating system is Linux – Mahdi Nov 29 '15 at 2:19
2

Looks like an arguments misplacing. Try

taskset -c 30 -p <pid>
  • 1
    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 2:40
1

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.

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