I looked up for similar topics on this website and could not really find a solution. The answers were always shallow and confusing for rookie like myself.
I have a task to create a C language program that will display how many processes were running on average in certain amount of time. As you can see, the stopwatch part of a program is piece of cake. The problem is I do not know how to get number of processes running.
The only condition I have is to use system calls to get the number.
While I was searching internet I found following code
struct kinfo kinfo;
int nr_tasks, nr_procs;
getsysinfo(PM_PROC_NR, SI_KINFO, &kinfo);
nr_procs = kinfo.nr_procs;
printf("Number of processes: %d", nr_procs);
When I write this code for example, I get a bunch of errors. As you can see there is plenty of undefined variables and no information about included libaries.
I could not even execute getsysinfo() function becouse I don't know how to include it in my c file.
I have to mention that program itself is working properly (I tested it with simple "hello world").
I would appreciate a little bit detailed advice on this problem since I do not have big knowledge at operative systems.