The Fibonacci sequence is the series of numbers 0, 1, 1, 2, 3, 5, 8, ....Formally, it | StudySoup

Textbook Solutions for Operating System Concepts

Chapter 4 Problem 4.26

Question

The Fibonacci sequence is the series of numbers 0, 1, 1, 2, 3, 5, 8, ....Formally, it can be expressed as:fib0 = 0fib1 = 1fibn = fibn1 + fibn2Write a multithreaded program that generates the Fibonacci sequence.This program should work as follows: On the command line, the userwill enter the number of Fibonacci numbers that the program is togenerate. The program will then create a separate thread that willgenerate the Fibonacci numbers, placing the sequence in data that canbe shared by the threads (an array is probably the most convenientdata structure). When the thread finishes execution, the parent threadwill output the sequence generated by the child thread. Because theparent thread cannot begin outputting the Fibonacci sequence until thechild thread finishes, the parent thread will have to wait for the childthread to finish. Use the techniques described in Section 4.4 to meet thisrequirement.

Solution

Step 1 of 6)

The first step in solving 4 problem number 26 trying to solve the problem we have to refer to the textbook question: The Fibonacci sequence is the series of numbers 0, 1, 1, 2, 3, 5, 8, ....Formally, it can be expressed as:fib0 = 0fib1 = 1fibn = fibn1 + fibn2Write a multithreaded program that generates the Fibonacci sequence.This program should work as follows: On the command line, the userwill enter the number of Fibonacci numbers that the program is togenerate. The program will then create a separate thread that willgenerate the Fibonacci numbers, placing the sequence in data that canbe shared by the threads (an array is probably the most convenientdata structure). When the thread finishes execution, the parent threadwill output the sequence generated by the child thread. Because theparent thread cannot begin outputting the Fibonacci sequence until thechild thread finishes, the parent thread will have to wait for the childthread to finish. Use the techniques described in Section 4.4 to meet thisrequirement.
From the textbook chapter Threads you will find a few key concepts needed to solve this.

Step 2 of 7)

Visible to paid subscribers only

Step 3 of 7)

Visible to paid subscribers only

Subscribe to view the
full solution

Title Operating System Concepts  9 
Author Abraham Silberschatz, Peter B. Galvin, Greg Gagne
ISBN 9781118063330

The Fibonacci sequence is the series of numbers 0, 1, 1, 2, 3, 5, 8, ....Formally, it

Chapter 4 textbook questions

×

Login

Organize all study tools for free

Or continue with
×

Register

Sign up for access to all content on our site!

Or continue with

Or login if you already have an account

×

Reset password

If you have an active account we’ll send you an e-mail for password recovery

Or login if you have your password back