Comp. Sys. Org. II, Project 1: Process management
Assigned: Feb. 3
Due: Feb. 24
The first project involves taking an existing simulator for a
toy machine, which runs a single process, and extending it to run
Please note: There is a lot of stuff attached to this project,
but some parts of it is much more important than others, and it will all
make better sense if you work through it in the intended order.
The project is not, technically, very difficult. My solution involved writing
about 80 lines of quite straightforward C code; in a more compressed style, I
imagine you could do it in 40 lines. It requires no difficult mathematical
analysis, only simple features of C, and no clever systems hackery.
What it does require is that
you understand very precisely what the code is
supposed to do.
How to do this assignment
My recommendation would be to do things in the following order.
- 1. If you are not familiar with the UNIX environment running
on the i5 system, make sure that you can log into your i5 account,
and that you can create, compile, and execute a C program on i5.
- 2. Download
the three sample STML programs and
the C code for the Simulated Toy Machine
and make sure that you can compile and run the code on the STML programs.
- 3. Read the
specs for the Simulated Toy Machine
You do NOT have to spend much (or, actually, any)
time reading the section about the STML language.
- 4. Read the
Assignment for Project 1.
At this point, you should have a general idea of what this project entails.
- 5. Work fairly carefully through some of
example inputs and
In particular, you should compare the output, at debugging level 2,
for running two
processes with a given input concurrently against the outputs for running
the same processes with the corresponding inputs individually.
For a start, I would suggest comparing
Multiprogramming example 1 against
STM example 1 and
STM example 2.
You want to get to the point where you understand quite precisely why the
multiprogramming output does what it does. It is unlikely that you have
to work through all the examples.
- 6. Work through the C code provided, and figure out how the relevant
parts of the code work. The internal workings of the procedures "load_stm",
"show_inst", "get_inst", and "exec_inst" do not actually matter to
anything you will be doing, so you do not have to figure out how these
work (not that they're very difficult). You do have to understand what
- 7. Now you can start working on actually writing code for the project.
If you really understand the earlier parts of this, the code writing
should be easy.
You do not at any point have to figure out how the STML programs
work (not that they're very difficult); it is of no relevance
whatever to doing the assignment. However, some people are
uncomfortable unless they understand all aspects of whatever system
they are working on (an attitude that, alas, becomes increasingly difficult
to maintain as you progress in computer science). So I certainly don't
discourage you from working through these simple programs, and I will
be happy to answer questions about them in private discussion
(i.e. not during class time and not on the class mailing list.)
If you have specific, fairly focussed, questions, then the best thing to
do is to email them to the class list, or, if you think that a lot of your
classmates have the same question, during class time. If you are just
generally at sea, and have no idea what's going on, then probably you
should come see me in my office. You can either come during office hours
or make an appointment via email.
I entirely encourage you to discuss any aspect of the project with your
classmates. However, each student MUST write all his/her
own code individually. Any sharing of code will be considered as
CHEATING and dealt with accordingly.
If you take code taken from any source other than the code I have provided
in stm.c, you must acknowledge the source in comments in your code.
Submitting the project
Source code in C, including the code carried over from stm.c,
should be emailed to the grader, Jack Fan
(JackSFan@earthlink.net). Be sure to include your name, email address,
and ID number in a comment at the top of the source code. This project
must be done in C; no other programming language will be accepted.
The project must run on the i5 system.
Please note: Your program will be tested on examples other
than those provided here.
A program that does not compile gets a maximum of 20 points.
A program that does not get as far as beginning execution of each
of the STM modules gets a maximum of 50 points.
Good program structure and adequate commenting are worth 10 points.
Bugs and Errors
Please let me know by email about any bugs in the code or errors in the web
pages as soon as you find them.