zoukankan      html  css  js  c++  java
  • linux ps 查看线程

    ... Complex Processes - Threads...

    Some OSes, including other Unixes, have the seperate concept of a process optionally consisting of several seperate threads, or light weight processes. Each thread is part of the same program but are scheduled individually.

    Until comparatively recently Linux just had processes, but it provides a more versatile sort of fork, called clone, which allows more control over the relationship between parent and child, allowing them to share memory space, file handles, signals etc and so provide thread facilities using Linux processes

    Since Linux 2.4.19 (or so) threads can share the pid of the parent process and have a seperate thread id, tid . Most processes have just the one thread and so their tid is is same as their pid

    For more info see http://yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html for a tutorial on POSIX threads usage under Linux.

    refer

    Some CLI commands for viewing Process data...

    ps uax
    List all processes given some basic usage on utility use
    pstree
    Lists processes as a tree showing parental relationships
    pstree -p
    ditto but showing process numbers (pid)
    ps -eo pid,ppid,user,pgid,args --sort pid
    list all processes showing process id, parent pid, user name, process grop id and command arguments, sorted by pid
    ps -eLf
    list all processes showing pid, ppid, tid (LWP), and number of threads in group, NLWP

    An example of a thread.....

    UID        PID  PPID   LWP  C NLWP STIME TTY          TIME CMD
    ...
    root      1753     1  1753  0    2 Feb27 ?        00:00:01 auditd
    root      1753     1  1755  0    2 Feb27 ?        00:00:03 auditd
    

    Notice the same PID but with different LWP (TID).

     

     

    ps -eLf  (man ps)

    UID PID PPID LWP C NLWP STIME TTY TIME CMD xce
    746324 222631 776421 0 70 2012 ? 00:00:46 icebox --Ice.Config=/data/xce/Edm/bin/../data/node_edm1/servers/ControllerEdmDemoLoaderCache/conf xce 746324 222631 776422 0 70 2012 ? 00:00:24 icebox --Ice.Config=/data/xce/Edm/bin/../data/node_edm1/servers/ControllerEdmDemoLoaderCache/conf xce 746324 222631 776423 0 70 2012 ? 00:00:00 icebox --Ice.Config=/data/xce/Edm/bin/../data/node_edm1/servers/ControllerEdmDemoLoaderCache/conf xce 746324 222631 776424 0 70 2012 ? 00:00:02 icebox --Ice.Config=/data/xce/Edm/bin/../data/node_edm1/servers/ControllerEdmDemoLoaderCache/conf xce 746324 222631 776425 0 70 2012 ? 00:00:16 icebox --Ice.Config=/data/xce/Edm/bin/../data/node_edm1/servers/ControllerEdmDemoLoaderCache/conf xce 746324 222631 776426 0 70 2012 ? 00:00:00 icebox --Ice.Config=/data/xce/Edm/bin/../data/node_edm1/servers/ControllerEdmDemoLoaderCache/conf xce 746324 222631 776438 0 70 2012 ? 00:00:00 icebox --Ice.Config=/data/xce/Edm/bin/../data/node_edm1/servers/ControllerEdmDemoLoaderCache/conf xce 746324 222631 781158 0 70 2012 ? 00:00:00 icebox --Ice.Config=/data/xce/Edm/bin/../data/node_edm1/servers/ControllerEdmDemoLoaderCache/conf xce 746324 222631 781159 0 70 2012 ? 00:00:00 icebox --Ice.Config=/data/xce/Edm/bin/../data/node_edm1/servers/ControllerEdmDemoLoaderCache/conf xce 746324 222631 781160 0 70 2012 ? 00:00:00 icebox --Ice.Config=/data/xce/Edm/bin/../data/node_edm1/servers/ControllerEdmDemoLoaderCache/conf xce 746324 222631 781161 0 70 2012 ? 00:00:00 icebox --Ice.Config=/data/xce/Edm/bin/../data/node_edm1/servers/ControllerEdmDemoLoaderCache/conf xce 746324 222631 781162 0 70 2012 ? 00:00:00 icebox --Ice.Config=/data/xce/Edm/bin/../data/node_edm1/servers/ControllerEdmDemoLoaderCache/conf xce 746324 222631 158596 0 70 2012 ? 00:00:00 icebox --Ice.Config=/data/xce/Edm/bin/../data/node_edm1/servers/ControllerEdmDemoLoaderCache/conf xce 746324 222631 158597 0 70 2012 ? 00:00:00 icebox --Ice.Config=/data/xce/Edm/bin/../data/node_edm1/servers/ControllerEdmDemoLoaderCache/conf xce 746324 222631 158598 0 70 2012 ? 00:00:00 icebox --Ice.Config=/data/xce/Edm/bin/../data/node_edm1/servers/ControllerEdmDemoLoaderCache/conf xce 746324 222631 790396 0 70 Apr30 ? 00:00:05 icebox --Ice.Config=/data/xce/Edm/bin/../data/node_edm1/serv
  • 相关阅读:
    MySQL的索引
    Linux 恢复rm -rf命令所删除的达梦数据文件
    史上最全Oracle文件损坏处理办法(附实验步骤)
    【2020-MOOC-浙江大学-陈越、何钦铭-数据结构】树(第四周的笔记和编程作业)
    你以为运维就是修电脑?大错特错!盘点一个高级运维的一天
    ElasticSearch中的_source和store:既生瑜何生亮
    为什么你不想学习?只想玩?人是如何一步一步废掉的
    【程序员日记】快乐的一周嘛(第8期)(财富、快乐、技术)
    【2020-MOOC-浙江大学-陈越、何钦铭-数据结构】树(第三周的笔记和编程作业)
    SqlBulkCopy 批量插入
  • 原文地址:https://www.cnblogs.com/tangr206/p/3055341.html
Copyright © 2011-2022 走看看