Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For the assignment we will work with POSIX threads in order to do some mathematical calculating. Requirements: Use command line arguments as follows: I will

For the assignment we will work with POSIX threads in order to do some mathematical calculating.

image text in transcribed

image text in transcribed

Requirements:

Use command line arguments as follows:

I will test your program with varying command line parameters

The program must compile and run on the Odin machine with no warnings or errors.

Be written in C or C++.

Print out calculated answer and answer using log() with 14 digits of precision.

Use pthreads ( pthead_create() ). Start all the threads first then use pthread_join() to wait for each threads completion.

Inside each thread update a global variable and use locking mechanism (such as pthread_mutex_lock() ) to protect global variable

Correct usage of all pthread* functions. I run it here My calculated answer Math function answer

Do not lock out the entire thread, lock only the code that needs to be protected across threads.

All computation work must be done within thread

Each thread will perform the loop based upon the given number of iterations

Functions:

int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr);

- Use lock mutex when entering the region - Will block if already locked int pthread_mutex_lock(pthread_mutex_t *mutex);

- Use unlock mutex when exiting the critical region int pthread_mutex_unlock(pthread_mutex_t *mutex);

- Destroy mutex when done using the lock int pthread_mutex_destroy(pthread_mutex_t *mutex);

ln (x) (x - 1) - (x - 1)2 / 2 + (x - 1)3 / 3 - (x - 1) 4 / 4 + (x 1) 5 / 5 - (x - 1) 6 / 6+ If the value of x is in the interval (0,2) (in other words 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions