Windows 命令窗口查看线程的工具——PsList

本文介绍如何利用PsList工具进行线程查看与诊断,包括下载地址、使用方法及参数说明。PsList能帮助用户获取进程信息,显示线程详情,并解决运行时可能遇到的性能计数器错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

微软提供了Windows 命令窗口查看线程的工具——PsList,在配合jstack诊断问题时非常有用。PsList在PsTools这个工具集中,下载地址和用法如下:


下载地址:PsTools Download

Introduction

pslist expwould show statistics for all the processes that start with "exp", which would include Explorer.
-dShow thread detail.
-mShow memory detail.
-xShow processes, memory information and threads.
-tShow process tree.
-s [n]Run in task-manager mode, for optional seconds specified. Press Escape to abort.
-r nTask-manager mode refresh rate in seconds (default is 1).
\\computerInstead of showing process information for the local system, PsList will show information for the NT/Win2K system specified. Include the -u switch with a username and password to login to the remote system if your security credentials do not permit you to obtain performance counter information from the remote system.
-uusername If you want to kill a process on a remote system and the account you are executing in does not have administrative privileges on the remote system then you must login as an administrator using this command-line option. If you do not include the password with the -p option then PsList will prompt you for the password without echoing your input to the display.
-ppassword This option lets you specify the login password on the command line so that you can usePsList from batch files. If you specify an account name and omit the -p optionPsList prompts you interactively for a password.
nameShow information about processes that begin with the name specified.
-eExact match the process name.
pidInstead of listing all the running processes in the system, this parameter narrowsPsList's scan to tthe process that has the specified PID. Thus:
pslist 53
would dump statistics for the process with the PID 53.

How it Works

Like Windows NT/2K's built-in PerfMon monitoring tool, PsList uses the Windows NT/2K performance counters to obtain the information it displays. You can find documentation for Windows NT/2K performance counters, including the source code to Windows NT's built-in performance monitor, PerfMon, in MSDN.

Memory Abbreviation Key

All memory values are displayed in KB.

  • Pri: Priority
  • Thd: Number of Threads
  • Hnd: Number of Handles
  • VM: Virtual Memory
  • WS: Working Set
  • Priv: Private Virtual Memory
  • Priv Pk: Private Virtual Memory Peak
  • Faults: Page Faults
  • NonP: Non-Paged Pool
  • Page: Paged Pool
  • Cswtch: Context Switches

问题

在运行pslist时可能会遇到下面的错误,无法获取性能计数器:

C:\Users\maizb>pslist exp

pslist v1.3 - Sysinternals PsList
Copyright (C) 2000-2012 Mark Russinovich
Sysinternals - www.sysinternals.com

Processor performance object not found on MAIZBTP
Try running Exctrlst from microsoft.com to repair the performance counters.
解决方法:

1. 用管理员身份运行cmd

2. 执行 lodctr /r , 从系统备份存储中重建性能计数器设置

3. 重新运行pslist,结果如下:

C:\Users\maizb>pslist -d 7164

pslist v1.3 - Sysinternals PsList
Copyright (C) 2000-2012 Mark Russinovich
Sysinternals - www.sysinternals.com

Thread detail for MAIZBTP:


java 7164:
 Tid Pri    Cswtch            State     User Time   Kernel Time   Elapsed Time
7124   9        23     Wait:UserReq  0:00:00.000   0:00:00.015    0:24:25.580
8528   9      2651     Wait:UserReq  0:00:01.279   0:00:00.140    0:24:25.535
5064  10       301     Wait:UserReq  0:00:00.031   0:00:00.031    0:24:25.530
1828  11       274     Wait:UserReq  0:00:00.046   0:00:00.000    0:24:25.530
9652  11       294     Wait:UserReq  0:00:00.093   0:00:00.015    0:24:25.530
11880  11       301     Wait:UserReq  0:00:00.140   0:00:00.000    0:24:25.530
4524  10      1180     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:25.527
11916  10      2337     Wait:UserReq  0:00:00.062   0:00:00.000    0:24:25.504
4708  11        20     Wait:UserReq  0:00:00.046   0:00:00.000    0:24:25.493
3408  10       135     Wait:UserReq  0:00:00.015   0:00:00.015    0:24:25.493
10444   9         3     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:25.399
9736  11         4     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:25.396
2472  11         2     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:25.396
8148   9       524     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:25.382
9372   9      5838     Wait:UserReq  0:00:00.109   0:00:00.218    0:24:25.381
10608   9       517     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:25.369
11292  11      6986     Wait:UserReq  0:00:11.559   0:00:00.265    0:24:25.289
11832  11      7085     Wait:UserReq  0:00:10.062   0:00:00.218    0:24:25.285
9900   9         4     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:25.285
10936   8        54     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:25.120
7544   9        17     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:24.906
7440   9         9     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:24.861
9976   8         4     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:24.838
10276  10     34626     Wait:UserReq  0:00:00.000   0:00:00.062    0:24:24.837
11424   8       177     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:24.343
7452   8         6     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:23.929
10136  10      4793     Wait:UserReq  0:00:00.062   0:00:00.000    0:24:23.902
11368  10      4898     Wait:UserReq  0:00:00.015   0:00:00.000    0:24:23.902
9456   8       830     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:23.902
9804   9       778     Wait:UserReq  0:00:00.015   0:00:00.000    0:24:23.901
8164   8       306     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:23.901
12224   9       883     Wait:UserReq  0:00:00.015   0:00:00.000    0:24:23.901
10816   9       750     Wait:UserReq  0:00:00.015   0:00:00.000    0:24:23.901
11624   9      1134     Wait:UserReq  0:00:00.156   0:00:00.062    0:24:23.901
12176   9      5342     Wait:UserReq  0:00:02.449   0:00:00.234    0:24:23.901
8580   9       821     Wait:UserReq  0:00:00.031   0:00:00.000    0:24:23.901
5808   8     22504     Wait:UserReq  0:00:09.984   0:00:00.686    0:24:23.858
9924   9        73     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:23.850
9396   8        70     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:23.850
6212   8        70     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:23.850
4644   8        68     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:23.850
4836   8        61     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:23.849
10660   8        65     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:23.849
9316   8        66     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:23.849
9052   8        60     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:23.849
10812   8        77     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:20.222
5316   9         3     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:17.398
7460   8        63     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:17.354
8812   8        58     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:17.340
7156   8        41     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:17.338
6416   8        49     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:17.336
11376   8        47     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:17.334
10828   8        97     Wait:UserReq  0:00:00.031   0:00:00.000    0:24:17.331
9664   8        49     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:17.329
6964   8        46     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:17.327
7892   8        54     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:17.325
1896   8        46     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:17.322
7700   8       235     Wait:UserReq  0:00:00.062   0:00:00.000    0:24:17.320
11412   8        49     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:17.318
6932   8        46     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:17.317
10300   8        46     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:17.315
7364   8        48     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:17.313
8956   8        44     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:17.311
 168   8        55     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:17.308
11648   8     17400     Wait:UserReq  0:00:00.000   0:00:00.015    0:24:16.992
10884   9         6     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:16.727
8944   8        36     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:16.727
11524   8      1869     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:10.654
9376   9         3     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:10.539
1968   8      3259     Wait:UserReq  0:00:00.015   0:00:00.000    0:24:10.158
1816   8      3261     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:10.158
10432   8      3284     Wait:UserReq  0:00:00.015   0:00:00.000    0:24:10.158
10180   8      3384     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:10.158
5288   8      3335     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:10.158
10956   8      3230     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:10.158
9364   8      3238     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:10.157
8476   8      3436     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:10.157
9956   8      3313     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:10.157
10596   8      3139     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:10.157
4580   8       129     Wait:UserReq  0:00:00.015   0:00:00.000    0:24:10.141
9564   9      4676     Wait:UserReq  0:00:00.499   0:00:00.312    0:24:10.061
10524   8      3211     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:10.049
3412   8      3178     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:10.049
8368   8      3380     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:10.049
7052   8      3216     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:10.049
6352   8      3274     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:10.049
8228   8      3104     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:10.049
8260   8      3356     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:10.049
1836   8      3232     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:10.049
10904   8      3166     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:10.048
10448   8      3098     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:10.048
11928   8      1801     Wait:UserReq  0:00:00.000   0:00:00.015    0:24:10.048
6224   8        29     Wait:UserReq  0:00:00.015   0:00:00.000    0:24:09.956
12168  10        52     Wait:UserReq  0:00:00.000   0:00:00.000    0:24:08.580
11448   9       218     Wait:UserReq  0:00:00.156   0:00:00.015    0:24:08.579
4072   8        48       Wait:Queue  0:00:00.000   0:00:00.000    0:23:55.120
 728   8        49       Wait:Queue  0:00:00.000   0:00:00.000    0:23:55.120
9308  11         5       Wait:Queue  0:00:00.000   0:00:00.000    0:08:58.569



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值