Operating Systems
CIS*3110 (W12)


Assignment #1

Due: February 6, 2011 at 23:55h
(please see deliverables section below)

Key concepts: System calls; signal handling; resource management.


Read the following sections carefully to ensure that you know what is to be done and what is to be handed in. If the details aren't addressed successfully you will lose marks. Please refer to the coding style guidelines to provide direction regarding the format of the code you write. You are expected to work independently on this assignment (please see academic misconduct in computing for clarification if necessary).


Lockdown!

As an exercise to learn about signal handling, as well as expore some of the issues that arise in resource managment, we'll contrive a system with some unusual restrictions.

The idea in brief: in a misguided attempt at security, the operating system has been configured such that standard I/O channels, including the file system, are blocked to all processes. You have found a clever exploit to bypass this security, but it will only work for a single running process. You'll attempt to make use of this single process as a proxy for other processes to communicate with one another as a chat system.

The Problem

Imagine that you wish to make it possible for processes to communicate with one another in a UNIX environment; however, due to draconian security settings, all normal means of communication (i.e. files, pipes, sockets, streams---we'll learn about these later) have been blocked and made inaccessible. For example, you can imagine that the system is heavily monitored and any attempt to share a file, open a socket, etc. will be intercepted and your illicit act will be discovered. You have found a way to circumvent this security involving shared memory, but only a single process will be able to perform these functions. You have decided to build that program to be a proxy by which other processes can indirectly communicate using signals as a means of inter-process coordination.

To test your plan, you are going to write two (2) programs in C. One of them, called proxy, starts up and goes to sleep waiting for other processes to interact with it (this is the only process that can access the file system, or that can initialize a shared memory block). The other program you will write is called proxychat which will implement instant messenger-style behaviour allowing two chat clients to send strings to one another using the proxy process as the intermediary; note that many pairs of chat clients should be able to communicate at the same time without issue.

Note that the proxy process is the only process that is permitted to perform operations directly on the file system, and is the only process that can freely send/receive signals to/from other processes. The processes may only use the defined shared memory blocks for data transfer between processes, and can only use signals to communicate otherwise; however, they are allowed to execute any other system calls that do not deal with communication via other (forbidden) means.

You will need to carefully design a distributed "state" that is maintained at all times while the proxy is running as it is possible for it to be interacting with a number of different processes at any time and many events are asynchronous. It falls to a protocol to ensure everything works properly over time, regardless of the order in which events occur. This closely mimics the issues associated with resource contention in the operating system (you can think of the proxy resources similar to a single hard drive---there must be a means by which orderly access is permitted to the single shared resource).

You can make any reasonable assumptions regarding system behaviour otherwise (e.g. guaranteed delievery of signals, etc.) and can safely make use of these assumptions in implementing your protocol.

Mode of operation

You have the option to design the global behaviour of this system in one of two ways (that is to say, the choice is yours - implement it in one of these two forms; you are not required to support both modes of operation):

  1. point-to-point: the proxychat clients talk to only one other chat client. This would mimic an instant messager type experience.

  2. broadcast: the proxychat clients are all connected such that anything typed in any chat client is relayed to and appears in all other chat clients. This would be most like an IRC, or other "room-based" conversation system.
Neither of these is significantly easier or harder than the other; however, the details you need to pay attention to differ slightly. For example, in the broadcast case, it would be possible to let all clients read data from the shared memory area at the same time, if you have a reasonable method for tracking when they are all done.

Command-line operation

In the interest of consistency, you should adopt the following standards for the command-line operation of your programs.


Implementation Guidelines

Notes:

Makefile

You are responsible for writing a Makefile to compile your code. Typing "make", "make lockdown" or "make all" should result in the compilation of all required components with the result being your two programs (proxy and proxychat). You should ensure that all required dependencies are specified correctly.


Deliverables



Last Modified: 2012 / 01 / 31