Fibonacci Interface-Pipe-Thread Server

Write a Fibonacci server program that: The user interface program:

Sample Runs

The keyboard inputs are in italics.

This run does not reach the CPU limit. The user inputs were given in rapid succession.

> ThreadFibServer.out 100
S: Setting CPU limit to 100s
I: Which Fibonacci number do you want : 44
I: Which Fibonacci number do you want : S: Server has used 0s 1756us
S: Received 44 from interface
S: Created and detached the thread for 44
43
I: Which Fibonacci number do you want : S: Server has used 0s 515572us
S: Received 43 from interface
S: Created and detached the thread for 43
33
I: Which Fibonacci number do you want : S: Server has used 2s 210572us
S: Received 33 from interface
S: Created and detached the thread for 33
S: Fibonacci 33 is 3524578
42
I: Which Fibonacci number do you want : S: Server has used 3s 795963us
S: Received 42 from interface
S: Created and detached the thread for 42
0
I: Interface is exiting
S: Waiting for 3 threads
S: Waiting for 3 threads
S: Fibonacci 43 is 433494437
S: Fibonacci 42 is 267914296
S: Waiting for 1 threads
S: Fibonacci 44 is 701408733
S: Server has used 11s 654368us
S: Child 3948743 completed with status 0 

This run does reach the CPU limit. The user inputs were given in rapid succession.

> ThreadFibServer.out 4
S: Setting CPU limit to 4s
I: Which Fibonacci number do you want : 44
I: Which Fibonacci number do you want : S: Server has used 0s 1727us
S: Received 44 from interface
S: Created and detached the thread for 44
43
I: Which Fibonacci number do you want : S: Server has used 0s 602763us
S: Received 43 from interface
S: Created and detached the thread for 43
33
I: Which Fibonacci number do you want : S: Server has used 1s 793560us
S: Received 33 from interface
S: Created and detached the thread for 33
S: Fibonacci 33 is 3524578
42
I: Which Fibonacci number do you want : S: Server has used 2s 906340us
S: Received 42 from interface
S: Created and detached the thread for 42
0
S: Received a SIGXCPU, ignoring any more
S: Received a SIGXCPU, sending SIGUSR1 to interface
I: Received a SIGUSR1, stopping loop
I: Reading from user abandoned
I: Interface is exiting
S: Waiting for 3 threads
S: Waiting for 3 threads
S: Waiting for 3 threads
S: Fibonacci 42 is 267914296
S: Fibonacci 43 is 433494437
S: Waiting for 1 threads
S: Fibonacci 44 is 701408733
S: Server has used 12s 845677us
S: Child 3949093 completed with status 0 

This run does reach the CPU limit. The user inputs were given slowly.

> ThreadFibServer.out 4
S: Setting CPU limit to 4s
I: Which Fibonacci number do you want : 44
I: Which Fibonacci number do you want : S: Server has used 0s 1668us
S: Received 44 from interface
S: Created and detached the thread for 44
43
I: Which Fibonacci number do you want : S: Server has used 2s 71053us
S: Received 43 from interface
S: Created and detached the thread for 43
S: Received a SIGXCPU, ignoring any more
S: Received a SIGXCPU, sending SIGUSR1 to interface
I: Received a SIGUSR1, stopping loop
I: Reading from user abandoned
I: Interface is exiting
S: Waiting for 2 threads
33
S: Waiting for 2 threads
S: Waiting for 2 threads
S: Fibonacci 43 is 433494437
S: Waiting for 1 threads
S: Fibonacci 44 is 701408733
S: Server has used 9s 474782us
S: Child 3949066 completed with status 0 

Submission

Please review the policies on assessment in the administration document.

Solution