# Rick van der Zwet # 0433373 # OS Assigment 3 # Licence: BSD # $Id: README.txt 508 2008-03-02 14:18:40Z rick $ = Intro = File compiled on mac os x, gcc 4.0.1 = Files = Makefile = Makefile to generate executables of C code assignment3.c = Source code part A README.txt = Currently reading = Output part A = * Describe what this program does. # Creates handler for the signals SIGUSR1 and SIGUSR2 # Fork program to create child # Program main signals child, but as the handler is bound to the main # program it got received the parent itself # Child signals parent which is received by parent # Child returned * Change line 59 so it also sends SIGUSR1. What happens to the program's output? # SIGUSR1 is only received ones While still busy handling the first requests. All signals are blocked/ignored. Also see `man 2 sigaction` par 4 * Try removing the sleep statement from line 51,61 or both. Are both these sleep statements required? Disabling one or 2 sleep states does not change the program dehaviour on mac os x. NOTE: When adding a sleep statement in front of the line 58: kill(child_pid, SIGUSR1); the whole behaviour changes. It seems that the handlers are created shortly after the fork has been completed. I also build the code on a linux system with gcc 4.1.2 and all results changed. Removing the first sleep statements kill the calls from parent to child. Removing the second sleep statement does not change anything. Removing both will kill the call from parent to child. = Output part B = Code is to be found at nutt-lab-6-1.c. Rather verbose, lots of duplicate code lines, but working Calculating fibonacci number: 20 Child 1 fib = 6765, real time = 0 sec, 0 msec Child 1 fib = 6765, cpu time = 0 sec, 1 msec Child 1 fib = 6765, user time = 0 sec, 1 msec Child 1 fib = 6765, kernel time = 0 sec, 0 msec Child 2 fib = 6765, real time = 0 sec, 999 msec Child 2 fib = 6765, cpu time = 0 sec, 1 msec Child 2 fib = 6765, user time = 0 sec, 1 msec Child 2 fib = 6765, kernel time = 0 sec, 0 msec Parent fib = 6765, real time = 0 sec, 982 msec Parent fib = 6765, cpu time = 0 sec, 1 msec Parent fib = 6765, user time = 0 sec, 1 msec Parent fib = 6765, kernel time = 0 sec, 0 msec Calculating fibonacci number: 30 Child 1 fib = 832040, real time = 0 sec, 0 msec Child 1 fib = 832040, cpu time = 0 sec, 1 msec Child 1 fib = 832040, user time = 0 sec, 1 msec Child 1 fib = 832040, kernel time = 0 sec, 0 msec Child 2 fib = 832040, real time = 0 sec, 980 msec Child 2 fib = 832040, cpu time = 0 sec, 980 msec Child 2 fib = 832040, user time = 0 sec, 980 msec Child 2 fib = 832040, kernel time = 0 sec, 0 msec Parent fib = 832040, real time = 0 sec, 961 msec Parent fib = 832040, cpu time = 0 sec, 980 msec Parent fib = 832040, user time = 0 sec, 980 msec Parent fib = 832040, kernel time = 0 sec, 0 msec Calculating fibonacci number: 36 Child 2 fib = 14930352, real time = 0 sec, 558 msec Child 2 fib = 14930352, cpu time = 0 sec, 820 msec Child 2 fib = 14930352, user time = 0 sec, 820 msec Child 2 fib = 14930352, kernel time = 0 sec, 0 msec Child 1 fib = 14930352, real time = 0 sec, 0 msec Child 1 fib = 14930352, cpu time = 0 sec, 0 msec Child 1 fib = 14930352, user time = 0 sec, 0 msec Child 1 fib = 14930352, kernel time = 0 sec, 0 msec Parent fib = 14930352, real time = 0 sec, 545 msec Parent fib = 14930352, cpu time = 0 sec, 830 msec Parent fib = 14930352, user time = 0 sec, 830 msec Parent fib = 14930352, kernel time = 0 sec, 0 msec