90 likes | 254 Views
continued. Nutt Exercise III. Signal handlers. The complete program on p. 91 illustrates how a signal handler is registered with the signal() system call (see man page on cs01) Also illustrates how the whole signaling system operates Also illustrates the form of a signal handler
E N D
continued Nutt Exercise III
Signal handlers • The complete program on p. 91 illustrates how a signal handler is registered with the signal() system call (see man page on cs01) • Also illustrates how the whole signaling system operates • Also illustrates the form of a signal handler • See code on cs01, modified
Problem statement (Part A) • A: use ITIMER_REAL to implement your version of gettimeofday(). • Set it so it raises a signal once a second • Use signal facility to determine when ITIMER_REAL has been decremented to 0 and to count the number of seconds elapsed
Problem statement (Part B) • B: Design & implement facilities that use ITIMER_VIRTUAL and ITIMER_PROF interval timers to profile a process. • Profiler provides actual time of execution using timer from Part A • CPU time • User-space time • Kernel-space time
More on Part B • Use your gettimeofday() to compute program’s “wall clock” runtime • All times should have millisecond accuracy, even though you might not get this level of accuracy in reality • Use signal facility to create signal handlers to keep track of the number of seconds of virtual and profile time • Raise signal once a second
Problem statement (Part C) • Write a subject program to spawn 2 children, with each child recursively computing a Fibonacci sequence (the dumb way using f(n) = f(n-1)+f(n-2) directly) • Run it for n=20, 30, and 36 • Take note and report on the timer printouts