Homework 5: Multiprocessing on the STM

In this homework, you will convert the STM operating system to support multiple processing with a round-robin scheduler.

This involves the following changes and extensions:

Command line

The command line has the following form:
stm [-q QUANTUM] [-d DEBUGGING-LEVEL] [-m MAX] stml-file stml-file ...
where Note that the optional argument "-b BASE" from the original SML program is not needed.

Loading

At the beginning of execution, each SML file in the command line gives rise to a process. Each process is given a partition in memory of the size specified at the beginning of the SML file. Partitions are assigned in the order of the command line, starting at physical address 0. The SML code and data from the file is read into the bottom of the corresponding partition.

Process table

The process table should hold the following information for each process: You may assume that there are no more than 20 processes and that the name of the process is no more than 32 characters.

Process queue

You should maintain a FIFO queue of processes. When the running process is preempted, it is placed at the back of the queue. When the running process terminates or aborts, it is removed from the queue. When the queue is empty, the STM simulator halts.

Preemption and context switches

A context swith takes control away from the current process under four circumstances: Note that when a process is resumed, it is given exactly the standard time quantum, no more and less. It does not get extra or less time if it failed to use up its previous quantum.

Context switching involves the following:

Coding

The three functions "phys_address", "get_inst", and "exec_inst" correspond to the supposed hardware of the simulated machine. THESE MAY NOT BE CHANGED. You may change any of the other functions.