I compiled and install a new version of the kernel and now I have to make the new kernel support two new primitives, I explain more below

I have this file, **mysystemcalls-test.c** where I get the process and do forks in a **for** iteration. This is my test file.

```
//mysyscalls-test.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <mysyscalls.h>

#define NCHILDREN 10

int main()
{

  int pids[NCHILDREN], i;
  int original_parent = getpid();

  printf ("before fork: current number of children: %ld\n", getnchildren(1));

  for (i=0; i<NCHILDREN; i++) {
    pids[i] = fork();

    if (pids[i] == 0) {
    while (getppid() == original_parent);
      exit(0);
    }
  }
printf("after fork: current number of children: %ld\n", getnchildren(1));

for(i=0; i<NCHILDREN; i++)
  printf("pids[%d]:%d\tgetcpid(%d,1):%ld\n" ,i,pids[i],i,getcpid(i,1));

return 0;
}

```

The real problem is in the second file, **mysyscalls.h** I can't make the right call for the child process.

```
//mysyscalls.h

long getnchildren (int debug){
  int children;
  children = pids[i];
  return children;
}

long getcpid (int order, int debug){
  int childrenid;
  childrenid = getpid();
  return childrenid;
}

```

I don't know how to call these pids in the mysyscalls.h file. I searched and tested some code that I found here but I don't have an exact answer for my problem. I wrote that code but isn't working, it return the same pid.

It's supposed that **long getnchildren** returns the number of child processes that the calling process has, at the moment the primitive is called.

**long getcpid** returns the pid of the child of the calling process, at position order in the list of its children.