CS 3733 Operating Systems, Spring 2008 Recitation Review
Here is a review of the first 7 recitations.
- Recitation 8: POSIX Threads
In this recitation you learned how to compile and run threads under
Linux and Solaris.
Some of the things you should have experienced:
- Here you had a parent and child each calculating a
value and adding it to a sum. Since each had its own
sum variable, the value did not represent the sum
of the values calculated. The program is
here.
- Having the parent wait for the child to finish would
not help here.
- When the same is done with two threads, the threads
share the same sum variable so the sum represents the
sum of the two values. The original process joins the
thread before doing its calculation so there is no
interference. The program is
here.
- If the thread is not joined, what happens depends on
how the original process and the thread are scheduled.
You probably found that under Linux the program usually
gave the correct answer.
- Under Linux, if the reference to -lpthread was removed,
the program would not compile.
- When run under Solaris with the join commented out you
probably found that most of the time the original
process printed its results and exited before the
thread had a chance to execute.
- When run under Solaris, the original program ran as
expected.
- When you try to compile under Solaris without the
-lpthread, the compile is successful but the program
fails on the pthread_create.
- Recitation 9: POSIX Thread Synchronization
- In Part 7, you should use something like: countertest 10 10000000
with about 10,000,000 iterations.
- In Part 8, when you removed the synchronization, to should have
run faster and probably still gave the correct answers.
- In Part 9, when you replaced count++ with three lines, it still
ran fase, but gave the wrong answers.
- In Part 10, when you put the synchronization back, it ran
slower again but gave the correct answers.
- In Part 13, when I timed the running with synchronization, I got
The function_to_time took 8294753 microseconds
This is about 8 seconds.
- In Part 14, when I timed the running without synchronization, I got
The function_to_time took 637663 microseconds
This is about .6 seconds. Of course the count was incorrect also.
- So, 10,000,000 calls to the lock-unlock pair took about 7.6 seconds
or .76 microseconds per lock-unlock pair.
- Recitation 10: Network Communication
In this recitation you learned how to compile network programs under
Linux. You experimented with multiple connections to the server and
found that with multiple clients connecting to the same server,
you cannot predict which client gets the messages typed at the server.