Question: Objective: In this assignment, you will be writing a multithreaded program. You will demonstrate your knowledge of the POSIX Pthreads library and how to create,

Objective:

In this assignment, you will be writing a multithreaded program. You will demonstrate your knowledge of the POSIX Pthreads library and how to create, destroy, and wait for threads. You will also demonstrate how to pass data between parent and child threads.

Details:

You will create a multithreaded program that takes one or more numeric arguments from the command line and displays the prime factors (Linkof each number. Each child thread will be passed a number from the parent thread that should be factored by that thread. Each child thread will return a sorted integer array of prime factors for that number. The parent thread will wait for each thread to terminate. The parent thread will display the original number provided and all factors returned by the child thread to the console.

The child thread must not display any data. Your only output should be provided by the main thread, and only after waiting for the thread to complete.

Output:

Here are several examples of what is expected when you run your program:

# ./assn3 Usage:./assn3 ...

# ./assn3 12 12: 2 2 3

# ./assn3 7 12 25 7: 7 12: 2 2 3 25: 5 5

# ./assn3 {32..48} 32: 2 2 2 2 2 33: 3 11 34: 2 17 35: 5 7 36: 2 2 3 3 37: 37 38: 2 19 39: 3 13 40: 2 2 2 5 41: 41 42: 2 3 7 43: 43 44: 2 2 11 45: 3 3 5 46: 2 23 47: 47 48: 2 2 2 2 3

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!