Comp. Sys. Org. II (V22.0202.003)
Homework 5
Programming of Process Management
POSTSCRIPT: Apr 26, 2005
Here is the solution.
You may use the solution here
for doing the next STM assignment.
Assigned: Mar 31
Due: Apr 14
Introduction
In this homework, you will take an existing simulator for a
toy machine (STM), which runs a single process,
and extend it to run multiple processes.
The homework is not technically difficult,
but it involves many elements which you need to absorb.
So we suggest starting immediately.
There are two parts. In the first part, to help
you understand the STM architecture, we ask you to write
a simple gcd program for STM.
For the second (main) part, you are to modify STM so that it
supports multiple processes.
The actual programming involves writing
about 80 lines of straightforward C code; in a more compressed style,
you may be able to get away with 40 lines. It requires no difficult
analysis, only simple features of C, and no clever systems hackery.
How to do this assignment
We suggest doing things in the following order.
- Create a new directory, and download
stm.c
(the source code for the Simulated Toy Machine),
three sample STML programs
and a
Makefile.
You DO NOT have to figure out how the provided STML programs
work (though they're not difficult). But if you are curious,
I would be happy to discuss them with you.
- Compile and test the program using the given Makefile.
E.g., the default target will compile stm.c and run the primes.stm problem.
- Read the
specs for the Simulated Toy Machine
You do NOT have to spend much
time reading the section about the STML language.
- Read the
hw5 programming assignment.
At this point, you should have a general idea of
what the main part of this homework entails.
- Work through some of
example inputs and outputs.
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.
- 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 -- you only have to understand what they do.
- Write a STML program called "gcd.stm" that
reads a pair of numbers m and n, and spits out the sequence
of remainders, terminating when it reaches the value gcd(m,n).
This warm up exercise aims to give
a better understanding of the workings of STM.
- Now you can start working on actually writing code for this homework.
Getting help
If you have specific questions, you could
email them to the class list, the Grader and/or to me
(use your judgement).
NOTE: PLEASE use "yap@cs.nyu.edu" to
email to me. Do not use "cy1@nyu.edu" which I never read.
Collaboration
I encourage you to discuss any aspect of the project with your
classmates. However, each student MUST write all his/her
own code individually. No sharing of any code is acceptable.
If you take code taken from any source,
you must acknowledge the source in comments in your code.
Submitting your work
Please note the following steps carefully, as we reserve up to 10%
of the points to be deducted for failure to follow these instructions.
-
Your solution must be emailed to the grader, Chien-I Liao (cil217@nyu.edu),
but cc to me (yap@cs.nyu.edu).
-
Be sure to include your name, email address,
and ID number in a comment at the top of the source code. This programming
must be done in C; no other programming language will be accepted.
-
All your files should be packaged into a single tar file
called "hw5-xxxx.tar" where xxxx is your last name.
We do not want to handle multiple files.
-
Your submission must include the following files:
(0) a textfile file called README,
(1) a Makefile (with a capital "M") which is just an extension
of the Makefile which we provided,
(2) "gcd.stm" (your gcd program in STML),
(3) "stm-xxxx.c" which is your modified version of stm.c
(where xxxx is your lastname),
(4) the three programs primes.stm, fraction.stm, sort.stm.
REMARK: the last 3 programs is to ensure that we
can instantly test your program after unpacking the tar file.
-
Make sure that all your source codes are properly commented.
-
The README file must identify this project and you, and it must
give an overview of your modifications.
Data structures and important routines must be identified
and explained here.
-
The Makefile should include these targets:
(a) the default target should simply compile stm-xxxx.c.
(b) A target called "gcd" that runs stm-xxxx on your "gcd.stm".
(c) Two targets called "t1" and "t2" that test
stm-xxxx on multiple processes.
Grading
-
This homework is worth 120 points.
-
20 points will be for the "gcd.stm" code.
-
Your stm-xxxx program will be tested on examples other
than those provided here.
If it does not compile, you get a maximum of 25 points.
-
If it only gets as far as beginning execution of each
of the STM modules, you get a maximum of 50 points.
-
Good program structure and adequate commenting are worth 15 points.
-
Good test targets is worth up to 10 points.
-
Following our submission instructions is worth 10 points.