Solved: Write a multithreaded program that calculates various statistical valuesfor a | StudySoup

Textbook Solutions for Operating System Concepts

Chapter 4 Problem 4.21

Question

Write a multithreaded program that calculates various statistical valuesfor a list of numbers. This program will be passed a series of numbers onthe command line and will then create three separate worker threads.One thread will determine the average of the numbers, the secondwill determine the maximum value, and the third will determine theminimum value. For example, suppose your program is passed theintegers90 81 78 95 79 72 85The program will reportThe average value is 82The minimum value is 72The maximum value is 95The variables representing the average, minimum, and maximum valueswill be stored globally. The worker threads will set these values, and theparent thread will output the values once the workers have exited. (Wecould obviously expand this program by creating additional threadsthat determine other statistical values, such as median and standarddeviation.)

Solution

Step 1 of 6)

The first step in solving 4 problem number 21 trying to solve the problem we have to refer to the textbook question: Write a multithreaded program that calculates various statistical valuesfor a list of numbers. This program will be passed a series of numbers onthe command line and will then create three separate worker threads.One thread will determine the average of the numbers, the secondwill determine the maximum value, and the third will determine theminimum value. For example, suppose your program is passed theintegers90 81 78 95 79 72 85The program will reportThe average value is 82The minimum value is 72The maximum value is 95The variables representing the average, minimum, and maximum valueswill be stored globally. The worker threads will set these values, and theparent thread will output the values once the workers have exited. (Wecould obviously expand this program by creating additional threadsthat determine other statistical values, such as median and standarddeviation.)
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

Solved: Write a multithreaded program that calculates various statistical valuesfor a

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