Operating Systems and Computer Structures G2

Assignments

Overview

The purpose of the assignments is to introduce you to doing systems programming using the services supplied by the Operating System. This includes a shell program, a basic C program using the file system, a C program using multitasking, and a C program using remote procedure calls.

Rather than a set of unrelated exercises, the intention this year is to build a realistic program at the end, with the earlier exercises forming components or simpler versions. The program (or rather, programs) will give a basic version of the type of problem that is commonly talked about today with the increase in use of the Internet. The programs will provide a ``jukebox'' on the Internet, where a set of sound files are stored on one server computer on the network. This server can be queried for a list of the sound files, or can be requested to send a file to another machine where it can be played using the local sound card.


Select an assignment:

Assignment 1

Due date

This assignment is due on midnight, Sunday 20 August.

General

This assignment is to write a shell program. It makes use of three other programs list_sounds, fetch_sound, xselect and xwarn, supplied by the lecturer.

The purpose is to get the list of sounds and display them so that they can be selected by the user. Once selected, a sound file is fetched and played.

To avoid repeated fetches across the network of the same sound files, each file should be `cached' locally so that it can be reused if needed.

The concepts that are used in this assignment are

Supplied programs

The supplied programs are
list_sounds
This writes to standard output a list of lines, one per sound file. Each line consists of a filename followed immediately with a colon `:' (no white space), followed immediately by a description of the file. For example, petshop1:Petshop Boys ``Yesterday, when I was mad'' beatles1:Beatles ``Help'' beethoven5:Beethoven ``Fifth Symphony in C minor: First Movement'' The filename does not contain a colon `:'. The description does not contain the `{' or `}' characters.
fetch_sound
This program takes one argument, which should be the name of a file from list_sounds. If the file is valid, it writes to standard output the contents of the file. If successful, the exit code is 0, otherwise it is non-zero.
xselect
This program reads lines from standard input, and displays them as a list in an X Window. When an item from the list is selected, it is written to standard output. If the item contains white space, it is surrounded by curly brackets `{...}' as in {Beatles ``Help''}.
xwarn
This takes an arbitrary number of arguments, and displays them as a message in an error dialog box.

Specification

You should write a single bash shell program. It should obtain a list of sound files and their descriptions, and display the descriptions as a list using xselect. When the user selects a description, the corresponding sound file must be used.

A check should be made as to whether or not the sound file is in the local cache, that is, if it is stored in directory .sounds relative to the current directory. If it is, it should be used, otherwise it must be fetched across the network. When fetched, it must also be stored in the cache.

The sound file will be used by playing it i.e. by writing it to the device /dev/audio.

When the program exits, it must clean up the cache by removing the directory and all of its files.

Errors

If any errors occur, they should be reported using the command xerror. If they are fatal errors, the program should terminate, but otherwise continue.

Submission

Do not hand in a copy of the program on paper. Instead, hand it in electronically using the command give. This command runs with two parameters. The first parameter should be the string ``a1'' and the second should be the name of the file containing the source of your shell program. For example, if your shell file is called jukebox

    give a1 jukebox

You may run give any number of times. Each time you run give it replaces any earlier submission of the assignment. No record is kept of the number of submissions. It does not alter your file in any way - it just makes a copy in a place accessible only to the lecturer.

Other comments

If you want to use dialin access to work then some programs will need to be replaced. See here for more information.

If you are running Linux, then you will need binary copies of some programs. See here for more information.



Dialin access

Under construction.

Linux

Under construction.