Let’s round out this chapter with an example program. Its task is to
calculate fib(n) for a list of n, where fib(n) is the n^{th} Fibonacci number. (The Fibonacci sequence starts
0, 1. Each subsequent number is the sum of the preceding two numbers
in the sequence.)^{[28]} I chose this not because it is something we
all do every day, but because the naïve calculation of Fibonacci
numbers 10 through 37 takes a measurable number of seconds on typical
computers.

The twist is that we’ll write our program to calculate different Fibonacci numbers in parallel. To do this, we’ll write a trivial server process that does the calculation, and a scheduler that assigns work to a calculation process when it becomes free. The following diagram ...

Start Free Trial

No credit card required