1

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.

cyphar
  • 2,840
  • 1
  • 15
  • 25
Bozic
  • 159
  • 1
  • 12
  • "I" is always uppercase in English. – peterh Sep 04 '15 at 12:50
  • I'm not sure why you've used the `linux` and `linux-kernel` tags for a **Minix** problem. The way you'd do it in Linux is probably taking a look at `/proc`, but that's not going to help you. – cyphar Sep 05 '15 at 13:04

0 Answers0