Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Der zweite (Sohn-)Prozess gibt in seinem Programm sohn2.c einmalig den Text
- "Sohn_2", seine Prozessidentifikation und die seines Vaters sowie die Uhrzeit aus,
- durchläuft anschließend 10 mal eine Schleife, in der er zuerst bis
- MAX_COUNT=100.000.000 zählt und bei Erreichen einen "." ausgibt, und beendet sich.
- (Dieser Sohn verbraucht im Verhältnis zu Sohn_1 "viel" CPU-Zeit).
- */
- #include <stdio.h>
- #include <unistd.h>
- #include <string.h>
- #include <stdarg.h>
- #include <sys/wait.h>
- #ifndef MAX_COUNT
- #define MAX_COUNT 100000000
- #endif
- int main (int argc, char const *argv[])
- {
- int x,y;
- printf("Sohn_2: %d - %d\n", getpid(), getppid());
- if (fork())
- wait(0);
- else
- execlp("date", "date", NULL);
- for(x = 0;x < 10;x++)
- {
- y = 0;
- for(y = 0;y < MAX_COUNT;y++);
- printf(".");
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment