Video: https://youtu.be/86Wzw9MnxFo
Written version: https://cloudexplainers.com/linux-processes-vs-threads-when-each-one-wins/
Everything below ran for real in the video. Run it in a throwaway machine or container, never on a computer you care about.
The machine the video used, as files you can build it from:
# ana@ubuntu:~$
ps -u postgres -o pid,nlwp,args
ps -C mariadbd -o pid,nlwp,comm# ana@ubuntu:~$
ls -l /usr/sbin/nginx
ps -C nginx -o pid,user,nlwp,args# ana@ubuntu:~$
ps -T -p $(pidof mariadbd) | head -5
ls /proc/$(pidof mariadbd)/task | wc -l# ana@ubuntu:~$
counter --processes 4
counter --threads 4
counter --threads 4
counter --threads 4 --lock# ana@ubuntu:~$
crash --threads 4
crash --processes 4
sudo kill -9 40
ps -C nginx -o pid,user,nlwp,args
curl -sI localhost | head -1# ana@ubuntu:~$
spawn --threads 10000
spawn --processes 10000# ana@ubuntu:~$
nproc
burn --threads 4 & sleep 3; ps -C burn -o pid,nlwp,pcpu,comm; wait
burn --processes 4 & sleep 3; ps -C burn -o pid,nlwp,pcpu,comm; waitFrom Cloud Explainers. Lab files are MIT licensed (see the repository's LICENSE).