Linux: checking the parent id and its threads

In Linux, there variety of tools you can use to check on the processes, but most of these are just the same. One of them is ps or you can use htop.

In the following, I'm using ps just to show the processes and threads spawn by the parent process to create the threads processes.

[root@centos ~]# ps -p `pidof mysqlslap` -Lf
UID        PID  PPID   LWP  C NLWP STIME TTY          TIME CMD
root      6615 12502  6615  0    6 09:43 pts/1    00:00:00 mysqlslap --concurrency=5 --iterations=10 --query=select * from AddressCode; --user=root
root      6615 12502  6783  1    6 10:09 pts/1    00:00:00 mysqlslap --concurrency=5 --iterations=10 --query=select * from AddressCode; --user=root
root      6615 12502  6784  1    6 10:09 pts/1    00:00:00 mysqlslap --concurrency=5 --iterations=10 --query=select * from AddressCode; --user=root
root      6615 12502  6785  1    6 10:09 pts/1    00:00:00 mysqlslap --concurrency=5 --iterations=10 --query=select * from AddressCode; --user=root
root      6615 12502  6786  1    6 10:09 pts/1    00:00:00 mysqlslap --concurrency=5 --iterations=10 --query=select * from AddressCode; --user=root
root      6615 12502  6787  1    6 10:09 pts/1    00:00:00 mysqlslap --concurrency=5 --iterations=10 --query=select * from AddressCode; --user=root
[root@centos ~]# 


In the example above, I run this command using MySQL's builtin mysqslap to run a simple stress test to my existing database.

Sample command I used is,

mysqlslap --concurrency=5 --iterations=10 --query="select * from AddressCode;" --user=root -p --create-schema=testschema --no-drop


To understand how it's being listed, if you take closely on LWP, there are 5 of them are consecutively listed except for the 6615 which is the parent process. If you notice, LWP is the same as its PPID, 6615. LWP means the thread ID and NLWP means the total number of threads used by 6615 process id.

This is such a nice way to test the threads being spawned by an application when initialized or invoked.

Comments

Popular posts from this blog

Converting sectors into MB - Useful in understanding the sectors in iostat in Linux

What is Disk Contention?

Installing MySQL from source: Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)