CS611
Fall 2002
Programming Assignment 6
Due Sunday November 24


Implement a simple threads package for the IAS machine.

You should implement these two functions: thrCreate and thrYield.

The thrCreate function is passed two parameters. The first parameter is a function that should be executed by the newly created thread. The second parameter is a parameter to be passed to that function.

The thrCreate function returns 0 if it cannot create the thread. Otherwise it returns 1.

A FIFO list of active threads should be maintained. This list should be initialized upon the first call to a thread function and should initially contain the "main" thread, the thread of control created "automatically" when the process was created. When thrCreate is called, the newly created thread should be placed on the end of the list. Note: a newly created thread does not start executing immediately. Rather it is simply placed at the end of the list of active threads.

When thrYield is called, the currently executing thread should be moved to the end of the list of active threads and the thread that is now at the front of the list should become the thread that is now executing. If there is only one active thread, then that thread continues executing.

There is no status associated with a call to thrYield (i.e. it must succeed) so the primitive returns nothing.

When a thread returns from its "outermost" function, then the thread is terminated and it is removed from the list of active threads.

You should support at least five concurrently executing threads.

All labels in your code should begin with "thr" to avoid name conflicts when your code is combined with test code.

You should use the following function calling conventions:

Place your source code for thrCreate and thrYield, as well as any supporting code, into a file called "thr.asm".

Your program will first be graded for its general design. Your source code should start with a comment that documents your design. Be sure to discuss the following points:

Your discussion of your design will be worth 60 points.

Your program will be then be tested for correct functionality. The two functions, thrCreate and thrYield, will each be worth 20 points.

Good program structure and documentation is absolutely critical for assembly language programs. Therefore, you may lose points if your program is not properly structured or adequately documented.

Your assignment should be submitted for grading from a CIS Linux machine (e.g. turing.unh.edu). To turn in this assignment, type:
~cs611/bin/submit prog6 thr.asm

Submissions can be checked from a CIS Linux machine by typing:
~cs611/bin/scheck prog6

To receive full credit for the assignment, you must turn in your files prior to 8am on Monday November 25. Late submissions will be accepted at the penalty of 5 points per day up to one week late.

Remember: as always you are expected to do your own work on this assignment. Copying code from another student or from sites on the internet is explicitly forbidden!

If you developed your code on a DOS/Windows system, be sure to appropriately transfer your files to a CIS Linux system before submitting them. You need to convert the DOS ASCII file format to UNIX format. If you need help with this, please see me.


Last modified on November 11, 2002.

Comments and questions should be directed to hatcher@unh.edu