CS 3733 Operating Systems, Spring 2007 Assignment 4 Comments
This assignment was graded on a basis of 30 points.
- In the C code, rand must be protected also.
This is not the case in the Java code.
- In part 2, don't print the results if a mutex error occurs.
- There is adifference between:
public synchonized void addToSum(double c);
and
public static synchonized void addToSum(double c);
- Suppose Part3Tester has a synchronized run method.
What is the difference in Part3Tester between:
   Part3Tester extends thread: new Part3Tester
   Part3Tester implements Runable: new Thread(this)
- If you synchronize the run method:
either it does nothing (if each thread uses its own object)
or it makes the code completely serial.
- What is the difference between:
pthread_mutex_lock(&lock);
sum += sin(x) * sin(x);
pthread_mutex_unlock(&lock);
and
w = sin(x) * sin(x);
pthread_mutex_lock(&lock);
sum += w;
pthread_mutex_unlock(&lock);