COMP 3000 Lab 3 2010

From Soma-notes
Revision as of 09:41, 4 October 2010 by Praman (talk | contribs)
Jump to navigation Jump to search

Please answer all questions below.

Part A is designed to be done in the lab while part B is designed to be done on your own time. Many of the questions require you to compile and run sample programs. These programs can be compiled using either the Corel Lab computers or your SCS Linux account.

For all questions asking you to modify source code, you should always start with a clean version of the source code and modify that (unless otherwise directed in the question). Don’t continue modifying your solution to a previous question in order to answer the next question.

All programs given in this assignment are written in C. A makefile is provided to compile the core programs given by the assignment—type “make” to compile. If you wish to rename files, you will need to either edit the makefile or run GCC to compile the programs on your own.

Part A (Mandatory)

This part is to be completed in class.

You may add or edit tips after each question; please do not edit the original question, however.

Processes and Threads

  1. The program threads.c is a multithreaded producer/consumer program. Unfortunately it consumes faster than it produces, resulting in an error. Why does it not print the same number every time?
  2. The program passstr.c is a multithreaded program using the clone function call. What is wrong with the way this program blocks, waiting for the string to arrive in the buffer?

Part B (Optional)

The following exercises are optional.