CS 112 - Lab 4
Linked Queues/ Airport Simulation

Section 1: Introduction

The goal of this lab is to:

If you have not already done so, create a directory for this lab (and copy the lab 4 files into it. If you start off in your home directory you can do the following:

	mkdir ~/cs112/lab4
	cd ~/cs112/lab4
	cp ~cs112/lab4/* .

Section 2: Topics for Lecture

This week's lecture will include

Section 3: Description of Assignment

Lab 4 is based on the airport simulation program described on pages 140-151 in your textbook. The textbook version implements the two queues via circular arrays. You will implement your version with linked lists. Although linked lists can allow a queue to be appended as long as there is memory available, we will do as the book has and limit the queue size to a maximum defined in the include file plane.h as MAXQUEUE. MAXQUEUE is used to specify the limit an airport would place on the number of planes waiting to land or take off.

Section 4: Code Development

You will be provided the following files:
All the code in the plane.c, random.c, general.c and plane.h files can be used as is. All of the files (except plane.h which has been altered a little) is code from the book. The file main.c needs to be modified slightly to accommodate the change in implementation from arrays to linked lists. It is clearly marked WHERE those changes should be but we have not specified WHAT they need to be, that is up to you.

The include file plane.h also can be used as is. Your job is to write all the functions for linked list queue management as specified by the last seven prototypes in plane.h. Put these functions in a file named queue.c.

We have also provide the two files random_test.c and sample_output which you may use to test your simulation code. You should compile with random_test.c at first (not with random.h also or you will have duplicate functions) and execute your code with the 3 input parameters:

    30   (units of time for simulation, an integer),
0.47 (expected number of arrivals per unit time, a real), and
0.47 (expected number of departures per unit time, a real).
You can then compare your output with that contained in the file sample_output. Once, you are able to reproduce this output, you should then compile with random.c (and not random_test.c) and try different input parameters. Note: the real numbers used for the expected number of arrivals and departures (per unit time) must not sum to a value larger than one.

You also must create a makefile for this project.

Section 5: Handing in your C code and answers

When you have completed this lab assignment, you should have the following program(s) in your ~/cs112/lab4 directory (files in boldface should be either modified or created by you):

Do not leave the random_test.c and sample_output files in the same directory with the files listed above. These are for your own testing purposes and are not needed for grading. Your code will be tested for correctness using different sets of input parameters.

To submit your program(s) for grading, issue the command

~cs112/submit lab4

at your UNIX prompt. This utility program will copy your programs for grading and an electronic mail message will be sent to you to acknowledge your submission. You may check the status of your submission at any time by typing the command

~cs112/query lab4

at your UNIX prompt. You will automatically receive an electronic mail message confirming the status of your lab submission.

You should also answer the questions below and submit them in hardcopy to the TAs at the beginning of Lab 5 on February 28 (no late submissions accepted).

This weeks questions.

For credit on this lab, your software must be received by midnight February 27 and your answers to the lab questions must be received at the beginning of your lab section (8:00am or 11:10am) on Friday, February 28.

Note: Always bring your ID with you to lab.