Question: 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.

For the assignment we will work with POSIX threads in order to

do some mathematical calculating. Requirements: Use command line arguments as follows: I

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

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!