Operating Systems and Computer Structures G2

Assignment 3

Due date

This assignment is due by 5pm, 7 October at the end of week 12.

Introduction

This is an exercise in concurrent processing and inter-process communication using pipes and signal.

This assignment requires you to write a program to control another program by stopping and starting it. The other program plays a well-known radio station. The control program utilises an X-Window program with a stop and a start button.

Specification

You should write a C program that takes no parameters. This program should use two other programs, xonoff and play_radio . The program xonoff displays a window with two buttons, on and off. Each time the on button is pressed a ``1'' is written to stdout terminated by a newline, and each time the off button is pressed a ``0'' is written to stdout, terminated by a newline.

The program play_radio listens on the network for a broadcast radio and sends this to the builtin speaker on the Sun.

The program that you write has to use xonoff to provide two buttons to control play_radio . When the user clicks on the on button, the radio will play, and when the user clicks on the off button the radio will stop. The program will start off with the radio playing. The user can terminate execution by pressing ctrl-C in the xterm that started the program.

Errors

If your program cannot execute either of the two programs, it should cease with an error message.

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 ``a3'' and the second should be the name of the file containing your C program. For example,

    give a3 control_radio.c

You may run give any number of times. Each time you run give it replaces any earlier submission of the assignment.

Submit the C source code for your assignment, not the executable

Hints

Use a process for each of the programs, with a third to handle the output from xonoff and the control of play_radio. A program can be terminated by sending it the SIGKILL signal. Aternatively, it can be stopped and restarted by sending it the SIGSTOP and SIGCONT signals.