Question
The Fibonacci sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, ... Formally it can be expressed as: fib 0 =
The Fibonacci sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, ...
Formally it can be expressed as:
fib0 = 0
fib1 = 1
...
fibn = fibn-1 + fibn-2
Write a multi-threaded program that generates the Fibonacci sequence. This program should work as follows:
On the command line, the user will enter the number of Fibonacci numbers that the program is to generate.
Hint: Use the argc and argv parameters passed to main() from the command line
The program will then create a worker thread that will generate the Fibonacci numbers.
The sequence should be placed in data structure that can be shared by threads.
When the worker thread is finished, the parent thread will output the sequence generated by the worker.
Since the parent thread cannot begin outputting the Fibonacci sequence until the worker thread finishes, the parent will need to wait for the worker to finish
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started