next up previous
Next: About this document ... Up: Assignment 6: Synchronization Primitives Previous: Estimate the quantum size

Check out pthread mutexes

1.
Read the handout from Programming with POSIX threads that describes pthread mutexes. Print the documentation of the relevant system calls.

2.
Make a copy of lock.c and call it mutex.c. Change the implementation of make_lock, acquire and release so that they use pthread mutexes. This should be a trivial implementation, since mutexes are the same thing as locks. All you are doing is creating a veneer that changes the interface.

3.
Again, confirm that there are no synchronization errors for a large number of iterations.

4.
Time your program to compare the efficiency of my lock implementation with pthread mutexes. Which is faster? Where is the extra time spent, in user code, system code, or operating system overhead?

Have fun! Learn something!



Allen Downey
2000-04-01