CSL373/CS333N: Assignment 2 on Process control and IPC

Background reading

  1. Read from the OS books the sections (bed time stories) that deal with: CPU scheduling, processes, threads, IPC. Read from Unix Network Programming by W. Richard the sections on semaphores and shared memory. Also look at The Linux Programmer's Guide and read the corresponding man pages.
  2. The following are good sources for pthreads (thanks to Parag for unearthing them).
    1. http://pauillac.inria.fr/~xleroy/linuxthreads/.
    2. http://www.llnl.gov/computing/tutorials/workshops/workshop/pthreads/MAIN.html
    3. http://www.cs.nmsu.edu/~jcook/Tools/pthreads/pthreads.html
    4. http://phoenix.liunet.edu/~mdevi/pthread/Main.htm
    5. http://dis.cs.umass.edu/~wagner/threads_html/tutorial.html (this is the one Parag recommends)
    6. The new edition of Stevens' Book.
    Do not download the package - pthreads is built in to glibc.

Process Applications

Implement one of the following using pthreads and semaphores you may either use linux posix compliant semaphores, or use semaphores built using pthreads mutex locks - see Appendix A of the last pthreads tutorial above. Make sure that your solution is free of deadlock and starvation.
  1. hare and turtle
  2. Dining philosophers.


  1. To be done in groups of two.
  2. Exchange your tests with others.
  3. The last date of submission of solutions is Jan 25 (strict). Click here to submit.

Subhashis Banerjee / Dept. Computer Science and Engineering / IIT Delhi / Hauz Khas/ New Delhi 110016 / suban@cse.iitd.ernet.in