Hi I am trying create a system call that will count the number of forks that were called. I was going to change the fork system call so that it has a counter that will keep track of the number of times fork() was invoked. I was planning on adding a static variable to fork.h and then increment that everytime fork.c is called. I just don't understand what is going on in fork.c at all. Is this even the right approach?
The Linux kernel already maintains a count of the total number of forks in the system as a whole.
One of the tasks performed by copy_process()
, which does a lot of the work involved in forking, is to increment the total_forks
counter.
This counter is exposed to userland as the processes
line in /proc/stat
(by the code here).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With