Number of Running Processes on a Minix system from C code

前端 未结 8 1010
盖世英雄少女心
盖世英雄少女心 2021-01-03 06:14

So, this seemed simple at first, but after crawling Google and here, the answer doesn\'t seem as simple as I first thought.

Basically, I\'m editing a MINIX kernel as

8条回答
  •  囚心锁ツ
    2021-01-03 06:44

    So I have been having the same problem and found a solution. (MINIX 3.1) within the method to count the processes use this code: (This is ANSI C)

    It simply runs through the process table and counts the number of processes.

    I know this is an old thread but it might help someone in the future.

    #include "../pm/mproc.h"
    
    /* inside function */
    
    struct mproc *mp;
    int i, n=0;
    
    printf("Number of running processes:\n");
    
    getsysinfo(PM_PROC_NR, SI_PROC_TAB, mproc);
    
    for (i = 0; imp_pid == 0 && i != PM_PROCS_NR) continue;
        n++;   
    }
    
    printf("%d", n);
    
    /* function end */
    

提交回复
热议问题