Assignment 1 Revised: Starting at the BOTM CSCI 3431 Operating Systems Tami Meredith, Fall 2012 This assignment is worth 10% of your final grade. I will be examining all files in the directory named $HOME/CSCI3431/A1/. They must be date-stamped prior to Thursday October 17th . That is, they must be finished sometime on Wednesday. Overview The BOTM (Bank of Tami Meredith) is small and sincere. So that customers are adequately served, the BOTM is installing a network of bank machines and you have been assigned the task of writing the central server for that network. Your server will take incoming network action requests (e.g., deposit, withdraw), create a new process for each request, and have that process carry out the request. You will program this system in C, and it will compile with gcc not g++. You should structure a bank account as an abstract data type (ADT), with a clearly defined interface. The data for an account must be stored in main memory (i.e., you cannot use the file system for data storage). 1. Bank accounts are identified with a 6 digit account number (i.e., 000000 to 999999 inclusive). 2. Bank accounts have a balance stored in cents (never larger than can be stored in an integer). Naturally, a balance of 100 cents is displayed as $1.00 (and so on for other balances). This is normal in monetary applications. 3. Bank accounts also store a timestamp that records when the last modification to the account was completed. 4. The following actions are supported: open a c initialise account (a is an account number), with a balance of c cents. dep a c deposit into account a, the amount of c cents. wd a c withdraw from account a, the amount of c cents. trans a1 a2 c transfer from account a1 to account a2, the amount of c cents. int a calculate 5% interest (truncated) on account a and add it to the balance. fee a apply the monthly service fee of 499 cents to account a. These actions are sent, via the network from the client, as a single ASCII string with one space between elements, no leading whitespace, no trailing newline, and a terminating 0. Commands (e.g., open) are always lower-case. Account numbers are always 6 digits long. Amounts are integer values with no leading sign (e.g., no '+' or '-') and will always fit into a 32 bit integer. 5. The server runs continuously as a background process on CS.SMU.CA. Your client may run anywhere. The files client.c and server.c (on the course webpage) provide you with some basic code you may use to setup the networking component of the client-server system. To use this code you start the server as a background process. It waits until it receives a message from the client and then prints the message and returns it to the client. The server then terminates. The client, when run, sends a message to the server, waits for a reply, prints it, and then terminates. You will have to modify the server to handle incoming messages in an infinite loop and create a process for each one. We will be testing your code with our own client. 6. Because the bank is very trusting, customers are allowed to run a deficit. That is, their balance can go below zero. In later assignments, deficits will be handled more stringently. When an action is completed, the server returns, to the client, the ASCII string "OK" if an action was completed and "FAIL" otherwise. How this is all made to work is up to you. What is important is that the actions are each performed concurrently, each with its own process. You will have to implement some sort of data base (perhaps just a hash table based on account numbers) to store the balance of each account. For this assignment, you do not need to worry about overflow or underflow (i.e., values greater than INT_MAX or less than INT_MIN) as the student customers don't have very much money. Please place a text file called README in your directory with instructions on how to compile and execute your program. Any notes, comments, and so on that you wish to communicate to the marker should be in the README. The marker will read this file prior to evaluating your assignment. Requirements 1. Your server must execute on CS.SMU.CA 2. Your C code must be in a directory named $HOME/CSCI3431/A1/ 3. The file(s) specified in item 1 must compile to create an executable (or set of executables). 4. Your program must perform error checking and provide appropriate messages when an error is detected. 5. The program must satisfy the requirements listed in the Overview. 6. The C code you write must adhere to good programming practices. It should be indented, contain suitable comments, use preprocessor directives, and have intuitive variable names. Code that merely works and does not follow good practice DOES NOT meet the requirements. 7. We will be evaluating your server code with respect to: a) Correctness with respect to the specifications, b) Clarity and maintainability, c) Effective use of C, and d) Performance and efficiency. 8. We will not look at your client code at all. We are testing your server code with our own clients. We may stress-test your server.