[2] | 1 | # Rick van der Zwet
|
---|
| 2 | # 0433373
|
---|
| 3 | # OS Assigment 3
|
---|
| 4 | # Licence: BSD
|
---|
| 5 | # $Id: README.txt 508 2008-03-02 14:18:40Z rick $
|
---|
| 6 |
|
---|
| 7 |
|
---|
| 8 | = Intro =
|
---|
| 9 | File compiled on mac os x, gcc 4.0.1
|
---|
| 10 |
|
---|
| 11 |
|
---|
| 12 | = Files =
|
---|
| 13 | Makefile = Makefile to generate executables of C code
|
---|
| 14 | assignment3.c = Source code part A
|
---|
| 15 | README.txt = Currently reading
|
---|
| 16 |
|
---|
| 17 |
|
---|
| 18 | = Output part A =
|
---|
| 19 | * Describe what this program does.
|
---|
| 20 | # Creates handler for the signals SIGUSR1 and SIGUSR2
|
---|
| 21 | # Fork program to create child
|
---|
| 22 | # Program main signals child, but as the handler is bound to the main
|
---|
| 23 | # program it got received the parent itself
|
---|
| 24 | # Child signals parent which is received by parent
|
---|
| 25 | # Child returned
|
---|
| 26 |
|
---|
| 27 | * Change line 59 so it also sends SIGUSR1. What happens to the program's
|
---|
| 28 | output?
|
---|
| 29 | # SIGUSR1 is only received ones
|
---|
| 30 | While still busy handling the first requests. All signals are
|
---|
| 31 | blocked/ignored. Also see `man 2 sigaction` par 4
|
---|
| 32 |
|
---|
| 33 | * Try removing the sleep statement from line 51,61 or both. Are both
|
---|
| 34 | these sleep statements required?
|
---|
| 35 | Disabling one or 2 sleep states does not change the program dehaviour on
|
---|
| 36 | mac os x.
|
---|
| 37 |
|
---|
| 38 | NOTE: When adding a sleep statement in front of the line 58:
|
---|
| 39 | kill(child_pid, SIGUSR1); the whole behaviour changes. It seems that the
|
---|
| 40 | handlers are created shortly after the fork has been completed. I also
|
---|
| 41 | build the code on a linux system with gcc 4.1.2 and all results changed.
|
---|
| 42 |
|
---|
| 43 | Removing the first sleep statements kill the calls from parent to child.
|
---|
| 44 | Removing the second sleep statement does not change anything.
|
---|
| 45 | Removing both will kill the call from parent to child.
|
---|
| 46 |
|
---|
| 47 | = Output part B =
|
---|
| 48 | Code is to be found at nutt-lab-6-1.c. Rather verbose, lots of duplicate
|
---|
| 49 | code lines, but working
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 |
|
---|
| 53 | Calculating fibonacci number: 20
|
---|
| 54 |
|
---|
| 55 | Child 1 fib = 6765, real time = 0 sec, 0 msec
|
---|
| 56 | Child 1 fib = 6765, cpu time = 0 sec, 1 msec
|
---|
| 57 | Child 1 fib = 6765, user time = 0 sec, 1 msec
|
---|
| 58 | Child 1 fib = 6765, kernel time = 0 sec, 0 msec
|
---|
| 59 |
|
---|
| 60 | Child 2 fib = 6765, real time = 0 sec, 999 msec
|
---|
| 61 | Child 2 fib = 6765, cpu time = 0 sec, 1 msec
|
---|
| 62 | Child 2 fib = 6765, user time = 0 sec, 1 msec
|
---|
| 63 | Child 2 fib = 6765, kernel time = 0 sec, 0 msec
|
---|
| 64 |
|
---|
| 65 | Parent fib = 6765, real time = 0 sec, 982 msec
|
---|
| 66 | Parent fib = 6765, cpu time = 0 sec, 1 msec
|
---|
| 67 | Parent fib = 6765, user time = 0 sec, 1 msec
|
---|
| 68 | Parent fib = 6765, kernel time = 0 sec, 0 msec
|
---|
| 69 |
|
---|
| 70 | Calculating fibonacci number: 30
|
---|
| 71 |
|
---|
| 72 | Child 1 fib = 832040, real time = 0 sec, 0 msec
|
---|
| 73 | Child 1 fib = 832040, cpu time = 0 sec, 1 msec
|
---|
| 74 | Child 1 fib = 832040, user time = 0 sec, 1 msec
|
---|
| 75 | Child 1 fib = 832040, kernel time = 0 sec, 0 msec
|
---|
| 76 |
|
---|
| 77 | Child 2 fib = 832040, real time = 0 sec, 980 msec
|
---|
| 78 | Child 2 fib = 832040, cpu time = 0 sec, 980 msec
|
---|
| 79 | Child 2 fib = 832040, user time = 0 sec, 980 msec
|
---|
| 80 | Child 2 fib = 832040, kernel time = 0 sec, 0 msec
|
---|
| 81 |
|
---|
| 82 | Parent fib = 832040, real time = 0 sec, 961 msec
|
---|
| 83 | Parent fib = 832040, cpu time = 0 sec, 980 msec
|
---|
| 84 | Parent fib = 832040, user time = 0 sec, 980 msec
|
---|
| 85 | Parent fib = 832040, kernel time = 0 sec, 0 msec
|
---|
| 86 |
|
---|
| 87 | Calculating fibonacci number: 36
|
---|
| 88 |
|
---|
| 89 | Child 2 fib = 14930352, real time = 0 sec, 558 msec
|
---|
| 90 | Child 2 fib = 14930352, cpu time = 0 sec, 820 msec
|
---|
| 91 | Child 2 fib = 14930352, user time = 0 sec, 820 msec
|
---|
| 92 | Child 2 fib = 14930352, kernel time = 0 sec, 0 msec
|
---|
| 93 |
|
---|
| 94 | Child 1 fib = 14930352, real time = 0 sec, 0 msec
|
---|
| 95 | Child 1 fib = 14930352, cpu time = 0 sec, 0 msec
|
---|
| 96 | Child 1 fib = 14930352, user time = 0 sec, 0 msec
|
---|
| 97 | Child 1 fib = 14930352, kernel time = 0 sec, 0 msec
|
---|
| 98 |
|
---|
| 99 | Parent fib = 14930352, real time = 0 sec, 545 msec
|
---|
| 100 | Parent fib = 14930352, cpu time = 0 sec, 830 msec
|
---|
| 101 | Parent fib = 14930352, user time = 0 sec, 830 msec
|
---|
| 102 | Parent fib = 14930352, kernel time = 0 sec, 0 msec
|
---|