Question: Introduction A thread is a flow of control within a process. A multithreaded process contains several different flows of control within the same address space.

Introduction

A thread is a flow of control within a process. A multithreaded process contains several different flows

of control within the same address space. The benefits

of multithreading include increased

responsiveness to the user, resource sharing within the process, economy, and scalability factors, such

as more efficient use of multiple processing cores.

Thread libraries provide the application programmer with an API

for creating and managing threads.

Three primary thread libraries are in common use: POSIX Pthreads, Windows threads, and Java threads.

Each library provides

an API

to explicitly create and manage

thre

ads

.

Assignment

Write a

multithreaded

C

program

, YourLastName

-

YourFirstName

-

Assignment

-

3

.c,

that

calculates

various statistical values for a list of numbers

.

Analysis

and Remarks

This program will be passed a series of numbers on the command line and will then create three separate

worker threads. One thread will determine the average of the numbers, the second will determine the

maximum value, and the third will determine the min

imum value. For example, suppose your program

is passed the integers

90

81

78

95

79

72

85

The program will report

The average value is 82

The minimum value is 72

The maximum value is 95

The variables representing the average, minimum, and maximum value

s will be stored globall

y. The

worker threads will set these values, and the parent thread will output the values once the workers have

exited.

You

could obviously expand this program by creating additional threads that determine other statistical

values,

such as

median and standard deviation.

Perform necessary erro

r checking to ensure that a positive integer is passed on the command line

.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!