The Fibonacci sequence (https://en.wikipedia.org/wiki/Fibonacci_number) is the series of numbers 0, 1, 1, 2, 3, 5, 8, .... Write a multithreaded C++ program that generates the Fibonacci sequence using Pthread. The program should work as follows. The user will enter on the command line the number of Fibonacci numbers that the program is to generate. The program will then create a separate thread (child thread) that will generate the Fibonacci numbers, placing the sequence in a buffer/array (dynamically allocated in child thread). When the thread finishes execution, it returns the array to the calling/parent thread. Because the parent/calling thread cannot begin outputting the Fibonacci sequence until the child thread finishes, this will require having the parent/calling thread wait for the child thread to complete. You need to write the thread function and the main function. You may run & test your program in cs1 and copy-and-paste your code here for your answer. This problem aims to achieve the following goals: (1) understanding of thread function; (2) passing data to a thread; (3) retrieving data from a thread, and (4) familiarity with Pthread
The Fibonacci sequence (https://en.wikipedia.org/wiki/Fibonacci_number) is the series of numbers 0, 1, 1, 2, 3, 5, 8, .... Write a multithreaded C++
You may run & test your program in cs1 and copy-and-paste your code here for your answer. This problem aims to achieve the following goals: (1) understanding of thread function; (2) passing data to a thread; (3) retrieving data from a thread, and (4) familiarity with Pthread
Trending now
This is a popular solution!
Step by step
Solved in 2 steps