CS 3733 Operating Systems, Spring 2004 Assignment 4 Comments
Here are some general comments:
- Almost everyone did the first 3 parts correctly.
- For part 4, the mutex needs to have static storage class or the different
threads will use different mutexes and they will not synchronize.
Either define the mutex inside the function with the static
qualifier (best) or define it outside of any function.
- For Part 4, you need to lock th entire critical section.
- The thread function returns a pointer. You should not return 0 or
the value returned by pthread_mutex_unlock.
Extra credit:
- The return value of pthread_self() has type pthread_t
which might not be of integral type. You cannot assign this to an
int or compare it using ==.
- Comparing two variables of type pthread_t is not atomic.
- An assignment of a variable of type pthread_t is not atomic.
- Incrementing a global variable is not atomic.
- Only three people got more than one point on the extra credit.