Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. // --- /usr/src/mm/main.c
  2. PUBLIC int do_getprocid(void)
  3. {
  4.   unsigned i;
  5.   for(i=0; i<NR_PROCS; i++)
  6.     if((mproc[i].mp_flags & IN_USE) && mproc[i].mp_pid == pid)
  7.       return i;
  8.   return ENOENT;
  9. }
  10. // --- testproc.c
  11. #include <lib.h>
  12. #include <stdio.h>
  13.  
  14. int getprocnr(int pid)
  15. {
  16.   message msg;
  17.   msg.m1_i1 = pid;
  18.   return _syscall(MM, GETPROCID, &msg);
  19. }
  20.  
  21. int main(int argc, char *argv[])
  22. {
  23.   int pid = atoi(argv[1]);
  24.   int i = 0;
  25.   for(; i <= 10; i++) printf("%d: %d\n", pid+i, getprocnr(pid+i));
  26.   return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement