Environment: OS --debian + python3.
All the output info below ommit unimportant.
Get my computer's cpu info with cat /proc/cpuinfo :
cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model name : Intel(R) Celeron(R) CPU G1840 @ 2.80GHz
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
processor : 1
vendor_id : GenuineIntel
cpu family : 6
model name : Intel(R) Celeron(R) CPU G1840 @ 2.80GHz
physical id : 0
siblings : 2
core id : 1
cpu cores : 2
Here is mthreads.py to be tested.
import os
import threading
print(os.getpid())
def dead_loop():
while True:
pass
t = threading.Thread(target=dead_loop)
t.start()
dead_loop()
t.join()
Run it in a terminal with python3 mthreads.py,get the output 3455 which is the process id of python3 mthreads.py.
cat /proc/3455/status
Name: python3
Umask: 0022
State: S (sleeping)
Tgid: 3455
Ngid: 0
Pid: 3455
PPid: 2205
Threads: 2
Cpus_allowed: 3
Cpus_allowed_list: 0-1
Run it in terminal.
python3 mthreads.py
3455
1.There are 2 cpu in my pc,why the Cpus_allowed is 3 ,more than my cpu?
pstree 3455 -p
python3(3455)───{python3}(3456)
2.There aer 2 threads running now, 3455 is the process id ,3456 is the thread id , which is the other thread id? How to get the second thread id number?
3.I want to know which process id is running on which cpu (cpu0 ,cpu1 )?
