Using /proc/stat for the number of processes running on the system

Look at the documentation for proc(5), and you'll see this for the processes field:

Number of forks since boot.

So it's simply not the number you're looking for. ps will give you that as you already know, counting the directories with only numbers in their name under /proc is another approach.


Depending on whether you want to include threads or not, add the -L option to your ps command:

$ ps -A --no-headers | wc -l
359
$ ps -AL --no-headers | wc -l
967

Threads are not listed separately by ps by default. The point of threads is that they are multiple threads of execution inside one process address space.