How does the Linux system view the number of threads in a process?

  
                

The Linux system process is composed of threads. Of course, the number of threads under the Linux process is not fixed. It can be a process or multiple processes. This article will teach you how to view the number of threads in the Linux system?

First, use the Linux command to view the process of the number of threads

1, the top command, specific use is top -H

With this option, the top Each line does not show a process, but a thread.

2, use the ps command, the specific usage is ps -xH

This way you can view all existing threads, you can also use grep for further filtering.

3, use the ps command, the specific usage is ps -mq PID

This can see the number of threads generated by the specified process.

Second, the Linux system tools to view the Linux process

Look at this directory, /proc/5000/There is everything you want. In fact, stat represents some of the current information.

When using the ps command to view the process, the meaning of the process state respectively is as follows:

D can not interrupt sleep (usually in IO operation) Receive signal does not wake up and can not run, process Must wait until an interrupt occurs

R is running or runnable (in queue running queue)

S interruptible sleep (hibernate, blocked, waiting for the formation or acceptance of a condition To signal)

T The stopped process receives the SIGSTOP, SIGSTP, SIGTIN, SIGTOU signals and stops running

W is changing pages (2.6. before the kernel is valid)

X dead process (not turned on)

Z The zombie process has terminated, but the process descriptor exists until the parent process calls the wait4() system call to release the BSD-style

"high priority" (not nice to other users)

N low priority (nice to other users)

L page locked in memory (real time and custom IO)

s a message Header

l Multithreading (using CLONE _THREAD, like NPTL's pthreads)

+ In the foreground process group

The above is the way to view the number of threads in the Linux process. The number of threads in the Linux process is an important parameter of the process. It is also the information you should know to manage Linux processes.

Copyright © Windows knowledge All Rights Reserved