Credits
The material developed for this lab was developed by Prof. L. Felipe Perrone. Permission to reuse this material in parts or in its entirety is granted provided that this “credits” note is not removed. Additional students files associated with this lab, as well as any existing solutions can be provided upon request by e- mail to: perrone[at]bucknell[dot]edu
Create a directory for Lab 3 under your csci315/Labs directory. You will will write a few simple programs for this pre-lab, all of which should be committed to your git repository. Remember, that you should be committing files to your local repo incrementally, that is, as you develop each program. This will help you recover files you might accidentally corrupt. Students have run into situations in which small modifications made to code that “nearly” works end up introducing some hard to track down error. Think of committing intermediate work that you feel brings you one step closer to the final solution. And, it goes without saying, that you must always commit and push the final solution, as well.
Read sections 1 through 5 in the POSIX Threads Programming tutorial, by Blaise Barney, from Lawrence Livermore National Laboratory. Read the source code examples you find and make a strong effort to understand how they work. Pay particular attention to the topics of thread creation and thread termination, how one can pass parameters to a thread, and how one can synchronize the termination of threads (join).
Write a program called char-threads.c, which creates three threads that never terminate. The general shape of all three threads is similar, what is particular to each one is the character they print. Here is the general structure:
while (1) {
}
In your pre-lab.txt file jot down your observations regarding the following:
When you are done with this, you need to:
Write a program called mytime.c, which calls gettimeofday(2), passes the results to ctime(3), and then prints to the screen the resulting string. Whether you have used these functions before or not, take the time to read their man pages to understand what they do and how to use them.
When you are done with this, you need to:
Note: In order to earn full credit in this pre-lab assignment, you must have pushed your solutions to your remote git repo before the start of you actual Lab 3 session.