Colorado State University

Programming Assignment 2

CS 370: Systems Architecture & Software


Due date - 10:00PM on Sunday, March 9th, 2014 - Part A (100 points)

Due date - 10:00PM on Sunday, March 16th, 2014 - Part B (100 points)

Due date - 10:00PM on Sunday, March 30th, 2014 - Part C (100 points)

Due date - 10:00PM on Friday, April 4th, 2014 - Lab Report 2 (100 points) - No Late period


Programming Assignment 2 - Threads, Producer/Consumer, & Synchronization in Java & C

Version 1.0 - Initial Version
Version 1.1 - Added no late penalty on Lab Report 2

Objective of Assignment

The objective of this assignment is to introduce the student to the concept of producer/consumers, multithreading, and synchronized data structure in Java and C. This will be done by first creating a multi-threaded consumer/producer using a concurrent data structure (ArrayBlockingQueue) for the work queue, for part B modifying that program to use a non-concurrent data structure and a synchronized block instead, and for part C implement the same requirements in C using Pthreads.

Requirements for Part A - Multi-threading & Producer/Consumer in Java

Requirements for Part B - adding synchronization in Java

Requirements for Part C - Using Pthreads in C to accomplish the same

Sample output

carrot> javac waker_lab2_1.java
carrot> java ProdConsABQ 2 3

Producer started
Producer started
Consumer started
Consumer started
Consumer started
Producer added 4 to queue, size = 1
Consumer removed 4, computed the square of 4 = 16, queue size = 0
.
.
.
Consumer removed 3, computed the square of 3 = 9, queue size=4
Main program exiting after joining threads

Writeup and checkin

Writeup

In your writeup, you should include issues such as objective, methodology (fairly straight forward for this lab), issues encountered while implementing, and an analysis of the assignment. For this assignment, what did you learn about multi-threading? Producer/Consumer? What did the difference between parts A,B, and C show you? What was different between Java and C? What were the strengths and weaknesses of each? What problems did you encounter?

Imagine you are writing up your research to be reviewed by a team of professors or peers - that is the flavor of a lab writeup.

Part A

You should tar up 2 files and submit them electronically into RamCT. Please name the files using the convention described in each of the bullets below.

Part B

You should tar up 2 files and submit them electronically into RamCT. Please name the files using the convention described in each of the bullets below.

Part C

You should tar 3 files up and submit them electronically into RamCT. Please name the files using the convention described in each of the bullets below.

Lab Writeup

You should turn your lab writeup electronically into RamCT. This file should be professional in appearance, should be created using some kind of text processor, and should be submitted in .pdf format. The writeup should contain your name at the top of the first page and should have your name in the header of each page. An example of the lab report can be found here. Points will be awarded for completeness, grammar, and clarity.

Note: there is no late period for Lab Report 2

Please see here for details on the Late Policy for this class.



Copyright © 2014: Colorado State University for CS 370. All rights reserved.