Guest User

Untitled

a guest
May 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. /*
  2. Der zweite (Sohn-)Prozess gibt in seinem Programm sohn2.c einmalig den Text
  3. "Sohn_2", seine Prozessidentifikation und die seines Vaters sowie die Uhrzeit aus,
  4. durchläuft anschließend 10 mal eine Schleife, in der er zuerst bis
  5. MAX_COUNT=100.000.000 zählt und bei Erreichen einen "." ausgibt, und beendet sich.
  6. (Dieser Sohn verbraucht im Verhältnis zu Sohn_1 "viel" CPU-Zeit).
  7. */
  8. #include <stdio.h>
  9. #include <unistd.h>
  10. #include <string.h>
  11. #include <stdarg.h>
  12. #include <sys/wait.h>
  13.  
  14. #ifndef MAX_COUNT
  15. #define MAX_COUNT 100000000
  16. #endif
  17.  
  18. int main (int argc, char const *argv[])
  19. {
  20. int x,y;
  21.  
  22. printf("Sohn_2: %d - %d\n", getpid(), getppid());
  23.  
  24. if (fork())
  25. wait(0);
  26. else
  27. execlp("date", "date", NULL);
  28.  
  29. for(x = 0;x < 10;x++)
  30. {
  31. y = 0;
  32. for(y = 0;y < MAX_COUNT;y++);
  33. printf(".");
  34.  
  35. }
  36. return 0;
  37. }
Add Comment
Please, Sign In to add comment