CS 321 Spring 2012  >  Assignment 2

CS 321 Spring 2012
Assignment 2

Assignment 2 is due at 5 p.m. Friday, March 2. It is worth 25 points.

Procedures

E-mail answers to the exercises below to ggchappell@alaska.edu, using the subjectSA2”.

Note: This assignment requires system calls and libraries that may not be available on your OS. If this is a problem, then you can use NetRun to write and test your code. However, you do not use NetRun to turn it in.

Exercises (25 pts total)

Exercise A — Multi-Threaded Computation

Purpose

In this exercise, you will write a program with communicating threads.

Instructions

Write a complete C++ program that prints Fibonacci numbers 0 through 46. (These are 0, 1, 1, 2, 3, 5, 8, ....)

Notes

Exercise B — Processes & Pipes

Purpose

In this exercise, you will write a program that creates multiple processes, which communicate via pipes.

Instructions

Write a complete C++ program that spawns 5 new processes, each of which determines its process ID, user ID, and the time in seconds when it starts up, and communicates this information to another process, which prints the information to the standard output.

Notes

Coding Standards

The above requirement is absolute; if your code does not compile, then there is no point in turning it in.

In addition, to receive full credit, submitted code should satisfy the following conditions.


CS 321 Spring 2012: Assignment 2 / Updated: 24 Feb 2012 / Glenn G. Chappell / ggchappell@alaska.edu