CS 321 Spring 2013  >  Assignment 6

CS 321 Spring 2013
Assignment 6

Assignment 6 is due at 5 p.m. Friday, April 19. It is worth 25 points.


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

Exercises (25 pts total)

Exercise A — Key-Value Server


In this exercise, you will write a Multi-threaded TCP server that makes a key-value store accessible via atomic operations.


Write a complete C++ program that serves a key-value store over TCP/IP as described below.

Example Run

Exercise B — Questions about Exercise A


Answer the following questions about the program in Exercise A.

  1. The specification for the server requires each command to contain an ID, which is returned in the response. Why is this a good idea?
  2. Assuming clients cooperate, the server allows them to do mutex-style locking on the key-value store, or portions of the store. How can this be done?
  3. If locking is done as in the previous question, then a client might get a lock and then crash, resulting in a permanent lock. How can this problem be solved? (A very simple change would be for the server to preemptively release the lock after some period of time. This would solve the above problem. However, if no other change were made, then this would introduce a new problem that is just as bad: a client might think it has the lock when it actually does not.)

Further Notes on the Assignment

CS 321 Spring 2013: Assignment 6 / Updated: 14 Apr 2013 / Glenn G. Chappell / ggchappell@alaska.edu