In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to know which CPU kernel the Linux process is running on". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to know which CPU kernel the Linux process is running on".
There are several ways to find out which CPU kernel is scheduled to run a given Linux process or thread.
Method one
If a process is explicitly pinned to a specific kernel of CPU using the taskset command, you can use the taskset command to find the pinned CPU kernel:
The code is as follows:
$taskset-c-p
For example, if you are interested in the PID 5357 process:
The code is as follows:
$taskset-c-p 5357
Pid 5357s current affinity list: 5
The output shows that this process is pinned to CPU kernel 5.
However, if you don't explicitly fix the process to any CPU kernel, you'll get an affinity list similar to the following.
Pid 5357s current affinity list: 0-11
The output indicates that the process may be scheduled in any CPU kernel from 0 to 11. In this case, taskset cannot identify which CPU kernel the process is currently assigned to, and you should use the method described below.
Method two
The ps command tells you the CPU ID to which each process / thread is currently assigned (in the "PSR" column).
The code is as follows:
$ps-o pid,psr,comm-p
PID PSR COMMAND
5357 10 prog
The output indicates that the PID of the process is 5357 (named "prog") currently running on CPU kernel 10. If the process is not fixed, the PSR column changes the display depending on whether the kernel may schedule the process to different kernels.
Method three
The top command can also show which process CPU is assigned to. First, use the "P" option in the top command. Then press the "f" key, and the "Last used CPU" column appears in the display. The CPU kernel currently in use will appear under the "P" (or "PSR") column.
The code is as follows:
$top-p 5357
Compared to the ps command, the advantage of using the top command is that you can continuously monitor how CPU is allocated over time.
Method 4
Another way to check which CPU kernel a process / thread is currently using is to use the htop command.
Start htop from the command line. Press the key to enter "Columns", and PROCESSOR will be added under "Available Columns".
The CPU ID currently used by each process appears in the "CPU" column.
Please note that all the previously used commands taskset,ps and top assign the IDs of the CPU kernel to 0pr 1. However, htop allocates the CPU kernel IDs from 1 to N.
At this point, I believe you have a deeper understanding of "how to know which CPU kernel the Linux process is running on". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.