Goal: To be able to write a C, C++, or Java program using the shared memory programming constructs

Preparation:

Guidelines:

For this assignment you may share information about how to compile and execute programs in Unix. However, each of you is to write the code on your own and submit your own program for a grade.

What you turn in:

  1. Email to me a copy of your source code. I may ask for a demonstration of your program.

Program Specifications:

This programming assignment will involve the idea of modern-day banking using an ATM (Automatic Transaction Machine). This program works on the idea that multiple users sometimes share the same bank account. For this program, you will assume that a single account will be accessed by up to four different users. Commands that a user may want to perform to the account include adding an amount to the balance, subtracting an amount from the balance, and printing the current balance. Users will act independently and concurrently on the account. Since each user may add or subtract funds from the account, your program must use appropriate synchronization tools to ensure that the balance in the account is accurate and valid.

Write a C, C++, or Java program using the pthread library that consists of code for main, a user thread, and supporting functions as needed. The code for main must do the following:

The code for the user thread must read from the file according to its thread identifier. Until all lines in the file are read, the user thread will read the next command and perform it. Valid commands are to ADD amount, SUB amount, and GET a balance. The commands should do the following:

Grading:

For full credit, your program must run correctly on file1 only (one thread), or on file1 and file2 (two threads concurrently), or on file1 and file2 and file3 (three threads concurrently), or on all four files (four threads concurrently) on Prospero. You must follow all program specifications. Your program should be appropriately commented and formatted. This program is worth 10 points.