FreeBSD's ps
command prints a W
in the state
column to indicate that a process is swapped out. By default, ps
prints state
as the third column, so this will give you what you want:
$ ps ax | awk 'NR==1{print};$3 ~ /W/'
'NR==1{print}'
will give you the column headers. Omit it if you don't need or want them.
Note also that FreeBSD's top
displays swapped out processes with their name (the final column) surrounded by angle brackets.
Under normal circumstances Linux processes are not explicitly pinned to a given core, there's typically no reason to do that, but is possible.
You can manage process affinity using taskset
or view which process runs on which CPU in the present instant using ps with the field 'psr'.
Check current CPU affinity of process 27395:
$ ps -o psr 27395
PSR
6
Check affinity list of process 27395:
$ taskset -pc 27395
pid 27395's current affinity list: 0-7
Set affinity of process 27395 to CPU 3
$ taskset -pc 3 27395
pid 27395's current affinity list: 0-7
pid 27395's new affinity list: 3
Check current CPU affinity of process 27395:
$ ps -o psr 27395
PSR
3
To check if any process is pinned to any CPU, you can loop through your process identifiers and run taskset -p
against them:
$ for pid in $(ps -a -o pid=); do taskset -pc $pid 2>/dev/null; done
pid 1803's current affinity list: 0-7
pid 1812's current affinity list: 0-7
pid 1986's current affinity list: 0-7
pid 2027's current affinity list: 0-7
pid 2075's current affinity list: 0-7
pid 2083's current affinity list: 0-7
pid 2122's current affinity list: 0-7
pid 2180's current affinity list: 0-7
pid 2269's current affinity list: 0-7
pid 2289's current affinity list: 0-7
pid 2291's current affinity list: 0-7
pid 2295's current affinity list: 0-7
pid 2300's current affinity list: 0-7
pid 2302's current affinity list: 0-7
pid 3872's current affinity list: 0-7
pid 4339's current affinity list: 0-7
pid 7301's current affinity list: 0-7
pid 7302's current affinity list: 0-7
pid 7309's current affinity list: 0-7
pid 13972's current affinity list: 0-7
Best Answer
In htop, press F2 or Sto enter setup, then use the arrows to navigate the
Columns->Available Columns
menu, selectPROCESSOR
and Enterto add a processor column. Then q to get back to the main screen.