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.
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 0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started