aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Burwell <ben@benburwell.com>2015-04-01 20:47:40 -0400
committerBen Burwell <ben@benburwell.com>2015-04-01 20:47:40 -0400
commit4a04db9470cc0492a4bfb9752de14d8e12209177 (patch)
tree52ea5efdefb181ed9b76d3e749766f2924b69044
parentd8463e5ebbf8805c30ee6402e6667eb5f78446cc (diff)
add docs
-rw-r--r--docs/tech/TechMan.pdfbin0 -> 255028 bytes
-rw-r--r--docs/tech/TechMan.tex57
-rw-r--r--docs/tech/data_structures.tex95
-rw-r--r--docs/tech/overview_of_program.tex21
-rw-r--r--docs/tech/program_structure.tex118
-rw-r--r--docs/tech/source_code.tex41
-rw-r--r--docs/user/UserMan.pdfbin0 -> 188050 bytes
-rw-r--r--docs/user/UserMan.tex35
-rw-r--r--docs/user/description_of_commands.tex618
-rw-r--r--docs/user/overview_of_comhan.tex38
-rw-r--r--docs/user/summary_of_commands.tex20
-rw-r--r--docs/user/summary_of_errors.tex40
12 files changed, 1083 insertions, 0 deletions
diff --git a/docs/tech/TechMan.pdf b/docs/tech/TechMan.pdf
new file mode 100644
index 0000000..7192e92
--- /dev/null
+++ b/docs/tech/TechMan.pdf
Binary files differ
diff --git a/docs/tech/TechMan.tex b/docs/tech/TechMan.tex
new file mode 100644
index 0000000..d9ea3c4
--- /dev/null
+++ b/docs/tech/TechMan.tex
@@ -0,0 +1,57 @@
+\documentclass[11pt]{book}
+\usepackage{amsmath}
+\usepackage{amssymb}
+\usepackage{makeidx}
+\usepackage{graphicx}
+\usepackage{tabularx}
+\usepackage{listings}
+\usepackage{color}
+\usepackage{makeidx}
+
+\definecolor{dkgreen}{rgb}{0, 0.6, 0}
+\definecolor{gray}{rgb}{0.5, 0.5, 0.5}
+\definecolor{mauve}{rgb}{0.58, 0, 0.82}
+\definecolor{dkred}{rgb}{0.7, 0, 0}
+
+\lstset{frame=tb,
+ language=C,
+ aboveskip=3mm,
+ belowskip=3mm,
+ showstringspaces=false,
+ columns=flexible,
+ basicstyle={\small\ttfamily},
+ numbers=none,
+ numberstyle=\tiny\color{gray},
+ keywordstyle=\color{blue},
+ commentstyle=\color{dkgreen},
+ stringstyle=\color{mauve},
+ identifierstyle=\color{dkred},
+ breaklines=true,
+ breakatwhitespace=true
+ tabsize=3
+}
+
+\author{B. Burwell and A. Morash}
+\title{MPX--OS Technical Manual}
+\date{Fall 2013}
+
+\makeindex
+
+\begin{document}
+
+\maketitle
+
+\frontmatter
+\tableofcontents
+
+\mainmatter
+\include{overview_of_program}
+\include{program_structure}
+\include{data_structures}
+\include{source_code}
+
+\printindex
+
+\backmatter
+
+\end{document} \ No newline at end of file
diff --git a/docs/tech/data_structures.tex b/docs/tech/data_structures.tex
new file mode 100644
index 0000000..0805caf
--- /dev/null
+++ b/docs/tech/data_structures.tex
@@ -0,0 +1,95 @@
+\chapter{Data Structures}
+\label{data_structures}
+
+\section{Process Control Block}
+\label{process_control_block}
+
+The operating system stores information about processes in a Process Control Block\index{Process Control Block} (PCB)\index{PCB}. Defined in {\tt mpx.h}, the PCB stores the following information:
+\begin{enumerate}
+ \item A pointer to the next PCB in the chain.
+ \item A pointer to the previous PCB in the queue.
+ \item A pointer to the next PCB in the queue.
+ \item A 9-character array to store the process name.\footnote{Note that thus, the maximum length of a process name is 8 characters, since character 9 will be {\tt 0x0}.}
+ \item A type (application or system).
+ \item A state (ready, running, or blocked).
+ \item A ``suspended'' flag.
+ \item A stack pointer for the process's stack.
+ \item An array of size {\tt STACK\_SIZE} to store the stack.
+ \item The address at which the process is loaded in memory.
+ \item The amount of memory allocated for the process.
+ \item A pointer to a parameter structure, storing the operation number and operation type for the process's current IO operation (if any).
+\end{enumerate}
+
+The actual code for the structure is listed here:
+
+\begin{lstlisting}
+struct pcbstruct {
+ struct pcbstruct * chain;
+ struct pcbstruct * next;
+ struct pcbstruct * prev;
+ char name[9];
+ short type;
+ short priority;
+ short state;
+ short suspend;
+ unsigned stack_ptr;
+ unsigned stack[STACK_SIZE];
+ unsigned loadaddr;
+ parm *parm_add;
+ int mem_size;
+};
+\end{lstlisting}
+
+Each process control block is linked to the next one (except for the last one, whose next PCB is {\tt NULL}) by a pointer for iteration purposes. Process control blocks can reside in at most one of several system-wide queues at any given time.
+
+\subsection{Ready Queue}
+
+The ready queue is maintained as a priority-ordered list of processes that are ready to be run. This way, the dispatcher knows which process to start next. Queue operations stored in {\tt pcb.c} use the {\tt next} and {\tt prev} fields of the PCB to create a doubly-linked list and is prioritized using the PCB's {\tt priority} field. By definition, the priority of an application process must be greater than the minimum priority and smaller than the maxiumum priority of a system process. In this way, we can assign the idle process to have the lowest possible priority and the command handler to have the highest possible priority.
+
+\subsection{I/O Queue}
+
+The I/O queue stores queue of processes involved in I/O operations. This queue is a normal FIFO queue, contrasted with the Ready Queue.
+
+\section{Device Control Block}
+\label{device_control_block}
+
+In order to manage I/O devices, MPX-OS uses Device Control Blocks,\index{Device Control Block} or DCBs. The {\tt struct} for the DCB is defined in {\tt mpx.h}, and is accessible to all component programs.
+
+The following information is stored:
+\begin{enumerate}
+ \item The current operation.
+ \item A pointer to the event flag used to signal completion.
+ \item A pointer to the PCB currently using the device.
+ \item A pointer to the head of the queue of PCBs waiting to use the device.
+ \item A far pointer to an int to store the length of the device buffer. The far pointer allows it to point to a different section of memory, since the variable will be declared in a user program.
+ \item A far pointer to a char array to store the I/O buffer.
+ \item A count of the number of characters in the buffer.
+ \item A char array to act as the ring buffer, implemented as a circular queue (see below).
+ \item The index of the front element of the ring buffer.
+ \item The index of the rear element of the ring buffer.
+ \item The number of characters in the ring buffer.
+ \item The maximum size of the ring buffer.
+\end{enumerate}
+
+The code for the DCB structure is listed below:
+\begin{lstlisting}
+struct dcb_struct {
+ unsigned current_op;
+ unsigned * event_flag;
+ pcb * current_pcb;
+ pcb * pcb_head;
+ far int * length;
+ far char * buffer;
+ int count;
+ far char * c_buffer;
+ char ring[INPUT_BUFFER_MAX];
+ int ring_front;
+ int ring_rear;
+ int ring_count;
+ int ring_size;
+};
+\end{lstlisting}
+
+\subsection{Ring Buffer}
+
+The ring buffer is used to implement type-ahead; that is, inputted characters are stored by the DCB when there is no current read operation and inserted into the buffer when a read request is made. There are several variables in the DCB structure used to implement the circular queue, whose logic is located in {\tt dcb.c}
diff --git a/docs/tech/overview_of_program.tex b/docs/tech/overview_of_program.tex
new file mode 100644
index 0000000..9b9a493
--- /dev/null
+++ b/docs/tech/overview_of_program.tex
@@ -0,0 +1,21 @@
+\chapter{Overview of the Program}
+\label{overview_of_program}
+
+The MPX Operating System is designed as an exercise to examine various concepts within the theory of operating systems (rather than as a consumer-usable system). It is specially constructed to be started from within MS-DOS, at which time it will ``take over'' the operating system to perform many of its tasks. As MS-DOS is interrupt-driven, it uses interrupt handler routines to perform many low-level services, such as performing I/O, keeping time using the CPU clock, etc. Thus, we can replace the functionality of the interrupt handlers with code we have written by modifying the interrupt vector table.
+
+MPX is written in C. The following files are used:
+\begin{enumerate}
+ \item {\tt mpx.h} --- A C header file containing all of the functions implemented, global variables, and {\tt \#DEFINE}d macros.
+ \item {\tt clock.c} --- Functions for enabling, configuring, and disabling the clock interrupt, as well as the function that is referenced in the interrupt vector table that is called when a clock interrupt occurs.
+ \item {\tt com.c} --- Functions for enabling, configuring, and disabling the {\tt COM} interrupts, as well as the function that is referenced in the interrupt vector table and is called when a clock interrupt occurs.
+ \item {\tt comhan.c} --- The code for the command handler, which is the main system process that prints a prompt and gets a user-inputted command.
+ \item {\tt dcb.c} --- Functions for dealing with Device Control Blocks (see page \pageref{device_control_block}).
+ \item {\tt direct.c} --- Functions for accessing MS-DOS directory listings. This code was provided by the project.
+ \item {\tt io.c} --- Functions for managing the queueing of processes with regard to I/O operations.
+ \item {\tt main.c} --- Contains {\tt main()}, which is called to perform setup tasks when MPX-OS first boots.
+ \item {\tt pcb.c} --- Functions for dealing with Process Control Blocks (see page \pageref{process_control_block}), including their queueing operations.
+ \item {\tt printer.c} --- Functions for enabling, configuring, and disabling the printer interrupts, as well as the function that is referenced in the interrupt vector table and is called when a clock interrupt occurs.
+ \item {\tt sys\_req.c} --- Contains the code for generating a software interrupt for when a system request is made from within MPX. This code was provided by the project.
+ \item {\tt sys\_sppt.c} --- System support, including initializing devices, closing devices, and handling system calls.
+\end{enumerate}
+
diff --git a/docs/tech/program_structure.tex b/docs/tech/program_structure.tex
new file mode 100644
index 0000000..dd887ce
--- /dev/null
+++ b/docs/tech/program_structure.tex
@@ -0,0 +1,118 @@
+\chapter{Program Structure}
+\label{program_structure}
+
+\section{Processes}
+
+\subsection{Types}
+
+Processes in MPX-OS can be one of two types: application or system processes. Application processes are any process that is loaded by a user. System processes are defined by MPX-OS for internal use; a user cannot load or run a system process. Precisely, MPX-OS defines two system processes, the first of which being the command handler. This process accepts and parses user commands to the operating system. The second system process is the idle process. This process does nothing, it only ensures that when the command handler is engaged in an I/O wait and is therefore blocked, there is something that can be running.
+
+\subsection{Prioritization}
+
+Each process has a priority. This allows more important processes, such as the command handler, to get more CPU time than less important ones, such as the idle process. A user can specify the priority of a process when it is loaded. Application processes can have priority $p_a$ where $-126 \le p_a \le 126$, and system processes can have priority $p_s$ where $-128 \le p_s \le 127$.
+
+\subsection{States}
+
+There are a number of states each process can be in, including {\tt READY}, {\tt RUNNING}, {\tt BLOCKED}, and {\tt ZOMBIE}. If a process is ready, it can be started immediately. It will then transition to the running state until it executes a system call. If it requests I/O, the process is blocked until the operation completes. If the user requests termination of the process while an I/O operation is in progress, the process will be placed in the zombie state. The I/O will complete, but immediately upon completion the process will be terminated. If the process requests termination, on the other hand, it is immediately terminated, the memory deallocated, and the PCB freed.
+
+\subsection{Suspension}
+
+A process can also be suspended, which is essentially pausing it. This is a user action; the user can put processes into and take them out of the suspended state arbitrarily. A suspended process will remain in the queue but will be skipped over when it is reached by the dispatcher.
+
+\section{System Call ({\tt sys\_call})}
+
+This function is called whenever one of MPX's processes is requesting a service, such as an I/O operation or termination. It is an interrupt function (its type is {\tt void interrupt}). The function is responsible for examining the parameters that have been placed on the stack, determining the corresponding operation, and executing it.
+
+\section{Dispatcher ({\tt dispatch})}
+
+The dispatcher is responsible for retrieving the next queued process and running it. It is also an {\tt interrupt} function. This means that the values of all of the registers will be pushed onto the stack before the function begins, and the registers are popped back off when it is finished.
+
+\section{Clock Operations}
+
+The clock interrupt functions in {\tt clock.c} are used to manage the system clock. When MPX-OS boots, it opens the clock for usage by MPX. A global {\tt long} is used to maintain the absolute number of clock ticks, which are configured to occur 18.2 times every second.
+
+The interrupt handler simply increments the counter variable. There is also a function for reading the clock value which takes pointers to {\tt int}s for storing the number of hours, minutes, and seconds that make up the number of ticks.
+
+It is of note that the clock will reset to zero when 24 hours are reached. Though partially for aesthetic reasons, it also ensures we do not overflow the capacity of a {\tt long} when running MPX-OS for an extended period of time.
+
+\section{I/O Drivers}
+
+\subsection{COM}
+The functionality for communicating with the {\tt com} port is contained in {\tt com.c}, which has the following functions defined:
+
+\subsubsection{\tt com\_open}
+
+If the COM port is already open, {\tt -2} will be returned. This function initializes the COM port by setting the clock rate's Most Significant Byte (MSB) and Least Significant Byte (LSB) correctly in the Line Control Register. The interrupt vector table is modified such that our interrupt handler will be called when a clock interrupt occurs.
+
+The function also needs to ensure that interrupts are enabled, now that they will be generated and handled properly. To do this, it sets bit 4 of the Interrupt Mask Register (IMR) to be zero. Bit 3 of the Modem Control Register is set to enable the MCR to receive interrupts from the UART. The Interrupt Enable Register is set to specify which serial interrupts should be enabled.
+
+Finally, the Device Control Block (page \pageref{device_control_block}) is initialized with the event flag.
+
+\subsubsection{\tt com\_close}
+
+To close the COM port, we simply restore pointer to the the MS-DOS interrupt handler in the interrupt vector table.
+
+\subsubsection{\tt com\_int}
+
+This is the function that handles COM interrupts. It saves the Base Pointer to return to later, and checks the IIR to see what the interrupt was from and calls either {\tt com\_write\_int} or {\tt com\_read\_int}, whichever is appropriate.
+
+\subsubsection{\tt com\_read}
+
+This function initializes a read operation from the COM port with the buffer and length pointers. Since these will be from other processes, they must be declared as {\tt far} pointers.
+
+\subsubsection{\tt com\_write}
+
+This function initializes a write operation from the COM port, similarly to how {\tt com\_read} works.
+
+\subsubsection{\tt com\_read\_int}
+
+This function is called when the COM port sends a character to the operating system. It is appended to the program buffer. If it was the last character for the buffer (determined by the {\tt length} pointer), a {\tt 1} is returned indicating that the I/O operation has finished. Otherwise, a {\tt 0} is returned.
+
+\subsubsection{\tt com\_write\_int}
+
+Similarly, this function is called when the COM port indicates it is ready to receive a character to be written. It takes the next character from the buffer and puts it into the holding register to be printed to the terminal.
+
+\subsection{Printer}
+
+The functionality for interfacing with the printer is stored in {\tt printer.c}, which contains the following functions:
+
+\subsubsection{\tt prt\_open}
+
+The printer is initialized by setting up the function pointer in the interrupt vector table, enabling printer interrupts on the 8259, clearing the init bit and setting the select bit on the Printer Control Register, and initializing the Device Control Block.
+
+\subsubsection{\tt prt\_write}
+
+To write to the printer, we save the buffer and length into the DCB, enable printer interrupts on PCR, strobing the printer, writing null to the Printer Data Register, and unstrobing the printer.
+
+When the printer is finished printing the null character, it will generate an interrupt to signal that it is ready to print the next character from the buffer.
+
+\subsubsection{\tt prt\_close}
+
+To close the printer, we disable printer interrupts using the Interrupt Mask Register and restore the MS-DOS interrupt vector.
+
+\subsubsection{\tt prt\_int}
+
+This is the function called when the printer is ready to receive a character. The base pointer is saved. If there are more characters to write, the printer is strobed, the next character from the buffer copied into the Printer Data Register, and the printer is unstrobed.
+
+If there are no more characters to write, the printer interrupts are disabled and the event flag is set. We then call {\tt IO\_complete}, passing the identifier of the printer device and the saved base pointer.
+
+The End of Interrupt is sent.
+
+
+\section{Scheduling}
+
+In MPX-OS, a Round-Robin dispatcher is implemented. There are several functions that handle scheduling tasks based on processes' pending I/O requests. All of this functionality is stored in {\tt io.c}, which implements the following:
+
+\subsubsection{\tt IO\_sup}
+
+The far pointers are made to the buffer and length. Then, the proper command based on the op number and op type is called. For example, if the op number refers to COM and the op type is write, {\tt com\_write} is called with the new far pointers. If the request was for a write operation to the console, we insert the process back into the ready queue, since this is not an interrupt-driven operation.
+
+\subsubsection{\tt IO\_complete}
+
+The DCB corresponding to the requested device is obtained. The stack pointer of {\tt cop} is set as the saved value. If the process was in the blocked state (as opposed to zombie if its termination had been requested by the user during the I/O operation), its state is set back to ready. In either case, it is placed back in the ready queue.
+
+If there are any pending I/O requests for the device that just completed, the processes requesting I/O are scheduled by calling {\tt IO\_sched}. Finally, the End of Interrupt signal is sent, and the dispatcher is called.
+
+\subsubsection{\tt IO\_sched}
+
+The operation number and type are determined and the appropriate DCB is accessed. If it has an I/O operation in progress, the process is added to the DCB queue and removed from the ready queue. Otherwise (if there is no operation in progress), the currently operating PCB for the DCB is set to the requesting process. \ No newline at end of file
diff --git a/docs/tech/source_code.tex b/docs/tech/source_code.tex
new file mode 100644
index 0000000..8ee7f32
--- /dev/null
+++ b/docs/tech/source_code.tex
@@ -0,0 +1,41 @@
+\chapter{Source Code}
+\label{source_code}
+
+\section{\tt mpx.h}
+\lstinputlisting{../../mpx.h}
+
+\section{\tt clock.c}
+\lstinputlisting{../../clock.c}
+
+\section{\tt com.c}
+\lstinputlisting{../../com.c}
+
+\section{\tt comhan.c}
+\lstinputlisting{../../comhan.c}
+
+\section{\tt dcb.c}
+\lstinputlisting{../../dcb.c}
+
+\section{\tt direct.c}
+\lstinputlisting{../../direct.c}
+
+\section{\tt io.c}
+\lstinputlisting{../../io.c}
+
+\section{\tt load.c}
+\lstinputlisting{../../load.c}
+
+\section{\tt main.c}
+\lstinputlisting{../../main.c}
+
+\section{\tt pcb.c}
+\lstinputlisting{../../pcb.c}
+
+\section{\tt printer.c}
+\lstinputlisting{../../printer.c}
+
+\section{\tt sys\_req.c}
+\lstinputlisting{../../sys_req.c}
+
+\section{\tt sys\_sppt.c}
+\lstinputlisting{../../sys_sppt.c}
diff --git a/docs/user/UserMan.pdf b/docs/user/UserMan.pdf
new file mode 100644
index 0000000..d27fe8d
--- /dev/null
+++ b/docs/user/UserMan.pdf
Binary files differ
diff --git a/docs/user/UserMan.tex b/docs/user/UserMan.tex
new file mode 100644
index 0000000..7e0a52f
--- /dev/null
+++ b/docs/user/UserMan.tex
@@ -0,0 +1,35 @@
+\documentclass[11pt]{book}
+\usepackage{amsmath}
+\usepackage{amssymb}
+\usepackage{makeidx}
+\usepackage{graphicx}
+\usepackage{tabularx}
+\usepackage{makeidx}
+
+
+\author{B. Burwell and A. Morash}
+\title{MPX--OS User Manual}
+\date{Fall 2013}
+\makeindex
+
+
+
+\begin{document}
+
+\maketitle
+
+\frontmatter
+\tableofcontents
+
+\mainmatter
+\include{overview_of_comhan}
+\include{summary_of_commands}
+\include{description_of_commands}
+\include{summary_of_errors}
+
+\printindex
+
+\backmatter
+
+
+\end{document} \ No newline at end of file
diff --git a/docs/user/description_of_commands.tex b/docs/user/description_of_commands.tex
new file mode 100644
index 0000000..0b2a3c4
--- /dev/null
+++ b/docs/user/description_of_commands.tex
@@ -0,0 +1,618 @@
+\chapter{Detailed Description of Each Command}
+\label{description_of_commands}
+
+\section{\tt version}
+\index{version@{\tt version}}
+\label{version_cmd}
+
+This command will display some information about the current version of MPX that is
+running.
+
+\subsection{Syntax}
+The command has the form {\tt version}.
+
+\subsection{Usage}
+The command can be called from the MPX prompt at any time.
+
+\subsection{Example}
+\begin{enumerate}
+ \item To get the version of MPX-OS that is currently running: \\
+ {\bf Input:} {\tt version} \\
+ {\bf Output:} {\tt MPX OS - Version 1.0}
+\end{enumerate}
+
+\subsection{Possible Errors}
+There are no error conditions.
+
+
+
+
+
+
+
+
+\section{\tt date}
+\index{date@{\tt date}}
+\label{date_cmd}
+
+This command is used to retrieve and set the system date. Note that the date does not
+actually increment as time passes.
+
+\subsection{Syntax}
+The command optionally takes a date string formatted as {\tt mm/dd/yyyy} where {\tt mm}
+is a two-digit one-based integer representing the month ({\tt 01} corresponding to January,
+{\tt 02} to February, and so on), {\tt dd} similarly corresponding to a one-based date of
+month, and {\tt yyyy} a year.
+
+The command has the form {\tt date [mm/dd/yyyy]}.\footnote{Note that in this document, we
+use {\tt [ ]} to denote optional parameters.}
+
+\subsection{Usage}
+The command can be called from the MPX prompt at any time.
+
+\subsection{Example}
+\begin{enumerate}
+ \item To get the current system date: \\
+ {\bf Input:} {\tt date} \\
+ {\bf Output:} {\tt 12/04/2013}
+ \item To set the system date: \\
+ {\bf Input:} {\tt date 12/04/2013} \\
+ {\bf Output:} None.
+ \item Attempting to set an invalid date: \\
+ {\bf Input:} {\tt date 99/99/9999} \\
+ {\bf Output:} {\tt Invalid date.}
+\end{enumerate}
+\subsection{Possible Errors}
+The message ``Invalid date'' will be displayed if the date is not in a valid format, i.e.
+the month is not between 1 and 12 or date not between 1 and 31, year not a number.
+
+
+
+
+
+
+
+
+\section{\tt directory}
+\index{directory@{\tt directory}}
+\label{directory_cmd}
+
+The directory command will display a listing of all available MPX programs that can be
+loaded and run, along with their sizes.
+
+\subsection{Syntax}
+
+The command has the form {\tt directory}.
+
+\subsection{Usage}
+
+The command can be called from the MPX prompt at any time.
+
+\subsection{Example}
+\begin{enumerate}
+ \item Get a listing of programs when there are none: \\
+ {\bf Input:} {\tt directory} \\
+ {\bf Output:} {tt You have no programs}
+ \item Get a listing of programs when there is one: \\
+ {\bf Input:} {\tt directory} \\
+ {\bf Output:} {tt You have 1 program}
+ \item Get a listing of programs when there are four: \\
+ {\bf Input:} {\tt directory} \\
+ {\bf Output:} {tt You have 4 programs}
+\end{enumerate}
+
+\subsection{Possible Errors}
+This command will not generate any errors.
+
+
+
+
+
+
+
+
+\section{\tt stop}
+\index{stop@{\tt stop}}
+\label{stop_cmd}
+
+The stop command allows the user to exit MPX-OS and return to DOS. When the command is
+issued, the user will be prompted to confirm their action by typing the character {\tt y}.
+If any other character is entered, the user will remain in MPX-OS.
+
+\subsection{Syntax}
+
+The command has the form {\tt stop}.
+
+\subsection{Usage}
+
+The command can be called at any time through the MPX prompt.
+
+\subsection{Example}
+\begin{enumerate}
+ \item User calls stop, but does not want to exit: \\
+ {\bf Input:} {\tt stop} \\
+ {\bf Output:} {\tt Are you sure you want to exit? [y/n]:} \\
+ {\bf Input:} {\tt n} \\
+ {\bf Output:} None.
+ \item User calls stop, and does confirm wanting to exit: \\
+ {\bf Input:} {\tt stop} \\
+ {\bf Output:} {\tt Are you sure you want to exit? [y/n]:} \\
+ {\bf Input:} {\tt y} \\
+ {\bf Output:} {\tt ** COMHAN execution complete **}
+
+\end{enumerate}
+\subsection{Possible Errors}
+
+There are no error conditions.
+
+
+
+
+
+
+
+
+\section{\tt help}
+\index{help@{\tt help}}
+\label{help_cmd}
+
+The help command allows the user to get help about using MPX commands. If the command is
+run with no options, a brief description of all commands. Alternately, if called with the
+name of a command as an option, it will give only the description of that command.
+
+\subsection{Syntax}
+
+The command has the form {\tt help [command]}.
+
+\subsection{Usage}
+
+The command can be called at any time through the MPX prompt.
+
+\subsection{Example}
+\begin{enumerate}
+ \item User wants help for all processes: \\
+ {\bf Input:} {\tt help} \\
+ {\bf Output:} \\
+ \begin{tabular}{ll}
+ {\tt Name } & \tt{Use } \\
+ {\tt ==================== } & \tt{=================================================} \\
+ {\tt version } & \tt{Display version number } \\
+ {\tt help } & \tt{Provide information about commands } \\
+ {\tt directory } & \tt{List .mpx files } \\
+ {\tt date [mm/dd/yyyy] } & \tt{Display or set the system date } \\
+ {\tt stop } & \tt{Terminate execution of COMHAN } \\
+ {\tt prompt string } & \tt{Change the prompt for commands } \\
+ {\tt alias command=string } & \tt{Create an alias for a command } \\
+ {\tt show } & \tt{Prints PCB information } \\
+ {\tt allocate } & \tt{Builds PCB with specified options } \\
+ {\tt free name } & \tt{Frees the PCB called name } \\
+ {\tt load name[=ppp] } & \tt{Creates a process called name with priority ppp } \\
+ {\tt resume name } & \tt{Resumes the process called name } \\
+ {\tt run name[=ppp] } & \tt{Runs a process called name with priority ppp } \\
+ {\tt suspend name } & \tt{Suspends the process called name } \\
+ {\tt terminate name } & \tt{Terminates the process called name } \\
+ {\tt setpriority name=ppp } & \tt{Sets the priority of process name } \\
+ {\tt dispatch } & \tt{Runs each process once } \\
+ {\tt clock [stop|start] } & \tt{Perform clock operations } \\
+ \end{tabular}
+
+ \item User wants help for the {\tt show} command: \\
+ {\bf Input:} {\tt help show} \\
+ {\bf Output:} \\
+ \begin{tabular}{ll}
+ {\tt Name } & \tt{Use } \\
+ {\tt ==================== } & \tt{=================================================} \\
+ {\tt show } & \tt{Prints PCB information } \\
+ \end{tabular}
+
+\end{enumerate}
+\subsection{Possible Errors}
+
+There are no error conditions for this command.
+
+
+
+
+
+
+
+
+\section{\tt prompt}
+\index{prompt@{\tt prompt}}
+\label{prompt_cmd}
+
+This command is used to alter the prompt that is displayed to the user by the command
+handler. For example, the user could change the prompt from the default {\tt mpx>} to
+{\tt >>}.
+
+\subsection{Syntax}
+
+The command has the form {\tt prompt string}, where {\tt string} is the new prompt.
+
+\subsection{Usage}
+
+The command can be called from the MPX prompt at any time.
+
+\subsection{Example}
+\begin{enumerate}
+ \item User wants to set the prompt to ``os'': \\
+ {\bf Input:} {\tt prompt os} \\
+ {\bf Output:} No output.
+\end{enumerate}
+
+\subsection{Possible Errors}
+
+If a {\tt string} is not passed, the user will receive the error ``No prompt specified.''
+
+
+
+
+
+
+
+
+\section{\tt alias}
+\index{alias@{\tt alias}}
+\label{alias_cmd}
+
+The alias command allows the user to make an alias for any of the commands. For example,
+if the user needs to access the value of the system clock in rapid succession, the
+{\tt clock} command could be aliased to simply {\tt c}.
+
+\subsection{Syntax}
+
+The syntax for this command is: {\tt alias command=new}, with {\tt command} the name of
+the command to be aliased, and {\tt new} the string that should be made equivalent to
+{\tt command}.
+
+\subsection{Usage}
+
+The command can be called from the MPX prompt at any time.
+
+\subsection{Example}
+\begin{enumerate}
+ \item Setting ``c'' to be an alias for ``clock'': \\
+ {\bf Input:} {\tt alias clock=c} \\
+ {\bf Output:} None.
+\end{enumerate}
+\subsection{Possible Errors}
+
+If {\tt command} or {\tt new} are not specified, the user will receive the error ``No
+prompt specified.''
+
+
+
+
+
+
+
+
+\section{\tt show}
+\index{show@{\tt show}}
+\label{show_cmd}
+
+The show command is used to view the status of various processes.
+
+\subsection{Syntax}
+
+The command is of the form {\tt show type}, where type is one of {\tt free}, {\tt all},
+{\tt system}, {\tt application}, {\tt suspended}, {\tt ready}, or {\tt init}.
+
+\subsection{Usage}
+
+\begin{enumerate}
+ \item[{\tt free}] Display all free process control blocks.
+ \item[{\tt all}] Display all process control blocks.
+ \item[{\tt system}] Display all system processes.
+ \item[{\tt application}] Display all application processes.
+ \item[{\tt suspended}] Display all suspended processes.
+ \item[{\tt ready}] Display all ready processes.
+ \item[{\tt init}] Display all processes that are waiting for I/O.
+\end{enumerate}
+
+If a type is not given by the user, a message describing the possible values is displayed.
+
+\subsection{Example}
+\begin{enumerate}
+ \item User wants a listing of all process control blocks: \\
+ {\bf Input:} {\tt show all} \\
+ {\bf Output:} A table of data about all process control blocks.
+\end{enumerate}
+\subsection{Possible Errors}
+
+If the type specified is not one of the valid types, an empty table will be displayed.
+
+
+
+
+
+
+
+\section{\tt load}
+\index{load@{\tt load}}
+\label{load_cmd}
+
+This command loads a program file into memory and prepares it for execution by MPX-OS.
+
+\subsection{Syntax}
+
+The command has the form {\tt load proc[=ppp]} where {\tt proc} is the name of the process
+to be loaded (and stored in the file {\tt proc.mpx}), and {\tt ppp} is an optional
+execution priority (default is zero). The priority $p$ must satisfy $-127 < p < 127$.
+
+\subsection{Usage}
+
+The command can be called from the MPX prompt at any time.
+
+\subsection{Example}
+\begin{enumerate}
+ \item User wants to load the process ``proc1'': \\
+ {\bf Input:} {\tt load proc1} \\
+ {\bf Output:} None.
+ \item User wants to load the process ``proc2'' with priority 100: \\
+ {\bf Input:} {\tt load proc2=100} \\
+ {\bf Output:} None.
+\end{enumerate}
+\subsection{Possible Errors}
+
+Several errors and warnings can occur when calling the command. If there is no file named
+{\tt proc.mpx} where {\tt proc} is the name argument to the load command, the message
+``Error: No program found with that name'' will be displayed and the program will not be
+loaded.
+
+If the program file does exist, but MPX-OS is unable to allocate sufficient memory for it
+to be loaded, the message ``Error: Insufficient memory'' will be displayed and the program
+will not be loaded.
+
+If there is sufficient memory, but the system encounters an error while loading the
+program file into memory, the message ``Error: Could not load program into memory'' will
+be displayed, and again, the program will not be loaded.
+
+If an invalid priority was specified by the user, the message ``Warning: invalid priority
+specified, using default'' will be displayed. MPX-OS will continue to load the program,
+but with zero as the priority.
+
+If there are no available process control blocks to allocate to the process, MPX cannot
+run the program at this time. In this case, the message ``Error: No free PCBs'' will be
+displayed and the program will not be loaded.
+
+In the case that there is an error building the process control block for the process that
+has been loaded into memory, MPX-OS will not be able to execute it. Thus, the memory will
+be deallocated and the message ``Error: Unable to build PCB'' will be displayed to the
+user.
+
+
+
+
+
+
+\section{\tt resume}
+\index{resume@{\tt resume}}
+\label{resume_cmd}
+
+The resume command allows a suspended process to continue running.
+
+\subsection{Syntax}
+
+The resume command has the format {\tt resume name|*}.\footnote{Note that we are using {\tt |} to denote ``or.''} If a {\tt name} is given, MPX-OS
+will attempt to find a process named {\tt name} and resume it. Otherwise, if {\tt *} is
+given, MPX-OS will resume all currently suspended processes.
+
+\subsection{Usage}
+
+The resume command is used when the user has suspended a process and wishes it to resume
+its execution.
+
+\subsection{Example}
+\begin{enumerate}
+ \item User wants to resume the process {\tt proc}: \\
+ {\bf Input:} {\tt resume proc} \\
+ {\bf Output:} None.
+ \item User wants to resume all processes: \\
+ {\bf Input:} {\tt resume *} \\
+ {\bf Output:} None.
+\end{enumerate}
+\subsection{Possible Errors}
+
+When {\tt resume} is called with no options, a message reminding the user to enter the
+name of a process to resume or an asterisk is displayed.
+
+If a name was given as the option, but MPX-OS cannot find a process with that name, the
+message ``No process named $x$'' will be displayed.
+
+Upon correct execution, there will be no output.
+
+
+
+
+
+\section{\tt run}
+\index{run@{\tt run}}
+\label{run_cmd}
+
+The run command behaves similarly to the load command, with the difference being quite
+minor. Whereas the load command simply allocated memory and set up a process control block
+for a process to be later run by a user using the resume command, the run command
+compresses these steps into one operation. Put simply, the run command does just that: it
+load a program from the disk and runs it.
+
+\subsection{Syntax}
+
+The command has the form {\tt run proc[=ppp]} where {\tt proc} is the name of the program
+(i.e., there is a file named {\tt proc.mpx}) and {\tt ppp} is the priority that should be
+used, where {\tt ppp} satisfies the condition $-127 < {\tt ppp} < 127$.
+
+\subsection{Usage}
+Usage
+\subsection{Example}
+\begin{enumerate}
+ \item User wants to run the process ``proc1'': \\
+ {\bf Input:} {\tt run proc1} \\
+ {\bf Output:} None.
+ \item User wants to run the process ``proc2'' with priority 100: \\
+ {\bf Input:} {\tt run proc2=100} \\
+ {\bf Output:} None.
+\end{enumerate}
+\subsection{Possible Errors}
+
+Since the run command first loads the process, all of the error messages from the load
+command can be obtained by using the run command.
+
+In addition, if there was an error loading the process, the message ``Error: process did
+not load correctly'' will be displayed.
+
+
+
+
+
+
+
+\section{\tt suspend}
+\index{suspend@{\tt suspend}}
+\label{suspend_cmd}
+
+The suspend command is used when a running program needs to be temporarily paused.
+
+\subsection{Syntax}
+
+The command has the form {\tt suspend proc|*} where {\tt proc} is the name of the program
+to be suspended. If the {\tt *} option is used, all running application processes will be
+suspended.
+
+\subsection{Usage}
+The command can be called whenever there is a running program.
+
+\subsection{Example}
+\begin{enumerate}
+ \item User wants to suspend the process {\tt proc}: \\
+ {\bf Input:} {\tt suspend proc} \\
+ {\bf Output:} None.
+ \item User wants to suspend all processes: \\
+ {\bf Input:} {\tt suspend *} \\
+ {\bf Output:} None.
+\end{enumerate}
+\subsection{Possible Errors}
+
+If there is no process named {\tt proc}, the message ``No process with the specified name''
+will be displayed.
+
+
+
+
+
+
+
+\section{\tt terminate}
+\index{terminate@{\tt terminate}}
+\label{terminate_cmd}
+
+The terminate command frees the PCB that was associated with an application process and
+frees the memory that was in use by the program.
+
+\subsection{Syntax}
+
+Similarly to the resume and suspend commands, the format is {\tt terminate name|*}, where
+{\tt name} corresponds to the name of the application process to be terminated, and {\tt *}
+to the fact that all application processes should be terminated.
+
+\subsection{Usage}
+
+The command can be run when there are currently running or suspended application processes.
+
+\subsection{Example}
+\begin{enumerate}
+ \item User wants to terminate the process {\tt proc}: \\
+ {\bf Input:} {\tt terminate proc} \\
+ {\bf Output:} None.
+ \item User wants to terminate all processes: \\
+ {\bf Input:} {\tt terminate *} \\
+ {\bf Output:} None.
+\end{enumerate}
+\subsection{Possible Errors}
+
+If there is no process called {\tt name}, the message ``No process with the specified name''
+will be displayed.
+
+
+
+
+
+
+
+\section{\tt setpriority}
+\index{setpriority@{\tt setpriority}}
+\label{setpriority_cmd}
+
+The setpriority command allows the user to specify an execution priority for a process.
+
+\subsection{Syntax}
+The format of the command is {\tt setpriority name=ppp} where {\tt name} refers to the
+name of the affected process and {\tt ppp} to the priority. As only the priority of
+application processes can be set, $-127 < {\tt ppp} < 127$ must be satisfied.
+
+\subsection{Usage}
+The command can be called when there is a non-zero number of application processes in MPX.
+
+\subsection{Example}
+\begin{enumerate}
+ \item Set the priority of programm {\tt proc} to be $-90$: \\
+ {\bf Input:} {\tt setpriority proc=-90} \\
+ {\bf Output:} None.
+\end{enumerate}
+\subsection{Possible Errors}
+
+There are two possible errors from this command. First, the priority could be invalid, in
+which case the message ``Error: invalid priority'' will be displayed. In the other, there
+is not really any process with the name specified, and MPX-OS will display ``Error: invalid
+process name.''
+
+
+
+
+
+
+
+\section{\tt clock}
+\index{clock@{\tt clock}}
+\label{clock_cmd}
+
+The clock command is used to perform various tasks using the system clock. The clock can
+be stopped and started, set to a particular value, or have its value read.
+
+\subsection{Syntax}
+
+The command uses the form {\tt clock job|time}, where {\tt job} is one of {\tt stop},
+{\tt start} and {\tt time} is a string formatted as {\tt hh:mm:ss} with {\tt hh} hours,
+{\tt mm} minutes, and {\tt ss} seconds.
+
+\subsection{Usage}
+
+The clock command can be called at any time from the MPX-OS command handler.
+
+\subsection{Example}
+\begin{enumerate}
+ \item Starting the clock: \\
+ {\bf Input:} {\tt clock start} \\
+ {\bf Output:} None.
+ \item Stopping the clock: \\
+ {\bf Input:} {\tt clock stop} \\
+ {\bf Output:} None.
+ \item Getting the clock value: \\
+ {\bf Input:} {\tt clock} \\
+ {\bf Output:} {\tt The current time is 21:09:44}
+ \item Setting the system clock: \\
+ {\bf Input:} {\tt clock 21:09:44} \\
+ {\bf Output:} None.
+\end{enumerate}
+\subsection{Possible Errors}
+
+If for some reason, the clock is unable to be set, the message ``Error setting clock''
+will be displayed.
+
+
+
+
+
+
+
+
diff --git a/docs/user/overview_of_comhan.tex b/docs/user/overview_of_comhan.tex
new file mode 100644
index 0000000..e4b10b1
--- /dev/null
+++ b/docs/user/overview_of_comhan.tex
@@ -0,0 +1,38 @@
+\chapter{Overview of COMHAN}
+\label{overview_of_comhan}
+
+\section{The Command Handler}
+
+All of your interactions with MPX-OS \index{MPX-OS} will be through the
+``Command Handler,'' \index{Command Handler} referred to
+as ``comhan.'' The command handler is a process that is loaded when MPX-OS first starts
+and allows users to execute commands such as getting help, running programs, setting the
+date, and other system-wide functionality.
+
+To use the command handler, you must only start MPX. You will see the prompt {\tt mpx>}
+which indicates that the system is ready to accept commands. You may then type in a
+command on the keyboard and press return. The command handler will then attempt to parse
+your command. If what you have entered is a valid system command, MPX will execute your
+request and then prompt you for the next command. If the text you enter at the MPX prompt
+is not valid, you will see an error message.
+
+Note that the command handler parses your input case insensitively; that is, typing
+{\tt version}, {\tt VERSION}, and {\tt vERsiOn} at the prompt will result in identical
+output.
+
+All of the commands used in MPX-OS are listed in \ref{summary_of_commands}. Alternately,
+when in MPX-OS, the command {\tt help} will display a list of commands and a brief usage
+description. Of particular note, however, is the {\tt stop} command, which will terminate
+MPX-OS and return control of the computer to DOS.
+
+\section{A Note on Errors}
+
+When writing MPX-OS, we have subscribed to the philosophy that the user does not need to
+know what the system is doing unless it pertains to their actions. Thus, for the most part,
+the normal behavior of a command is to see no output. For example, when changing the
+prompt (see p. \pageref{prompt_cmd}), there is no ``prompt changed'' message; the user
+should be able to trust the system to perform correctly.
+
+Thus, messages will generally only be displayed when some unexpected behavior has occurred.
+For full and more precise details on exactly what the output of each command, see the
+appropriate documentation in this Manual.
diff --git a/docs/user/summary_of_commands.tex b/docs/user/summary_of_commands.tex
new file mode 100644
index 0000000..31a644e
--- /dev/null
+++ b/docs/user/summary_of_commands.tex
@@ -0,0 +1,20 @@
+\chapter{Summary of Commands}
+\label{summary_of_commands}
+
+\begin{tabular}{r c l}
+ {\tt version} & Page \pageref{version_cmd} & Prints the currently running version of MPX-OS. \\
+ {\tt date} & Page \pageref{date_cmd} & Prints or updates the system date. \\
+ {\tt directory} & Page \pageref{directory_cmd} & Prints a listing of MPX programs that may be run. \\
+ {\tt stop} & Page \pageref{stop_cmd} & Stops MPX-OS and returns to DOS. \\
+ {\tt help} & Page \pageref{help_cmd} & Prints help on MPX commands. \\
+ {\tt prompt} & Page \pageref{prompt_cmd} & Changes the MPX prompt. \\
+ {\tt alias} & Page \pageref{alias_cmd} & Adds an alias for an MPX command. \\
+ {\tt show} & Page \pageref{show_cmd} & Displays a table of MPX processes. \\
+ {\tt load} & Page \pageref{load_cmd} & Loads a program. \\
+ {\tt resume} & Page \pageref{resume_cmd} & Resumes a suspended program. \\
+ {\tt run} & Page \pageref{run_cmd} & Runs a program. \\
+ {\tt suspend} & Page \pageref{suspend_cmd} & Puts a program into the suspended state. \\
+ {\tt terminate} & Page \pageref{terminate_cmd} & Terminates a program, freeing its resources. \\
+ {\tt setpriority} & Page \pageref{setpriority_cmd} & Sets the execution priority for a program. \\
+ {\tt clock} & Page \pageref{clock_cmd} & Prints or updates the system time. \\
+\end{tabular}
diff --git a/docs/user/summary_of_errors.tex b/docs/user/summary_of_errors.tex
new file mode 100644
index 0000000..45dbeae
--- /dev/null
+++ b/docs/user/summary_of_errors.tex
@@ -0,0 +1,40 @@
+\chapter{Summary of Error Messages}
+\label{summary_of_errors}
+
+\begin{tabular}{| l | c | c | c |}
+ \hline
+ \bf Error & \bf Command & \bf Section & \bf Page \\
+ \hline
+ Invalid date & {\tt date} & \ref{date_cmd} & \pageref{date_cmd} \\
+ \hline
+ No prompt specified & {\tt prompt} & \ref{prompt_cmd} & \pageref{prompt_cmd} \\
+ \hline
+ No prompt specified & {\tt alias} & \ref{alias_cmd} & \pageref{alias_cmd} \\
+ \hline
+ Error: No program found with that name & {\tt load} & \ref{load_cmd} & \pageref{load_cmd} \\
+ \hline
+ Error: Insufficient memory & {\tt load} & \ref{load_cmd} & \pageref{load_cmd} \\
+ \hline
+ Error: Could not load program into memory & {\tt load} & \ref{load_cmd} & \pageref{load_cmd} \\
+ \hline
+ Warning: invalid priority specified, using default & {\tt load} & \ref{load_cmd} & \pageref{load_cmd} \\
+ \hline
+ Error: No free PCBs & {\tt load} & \ref{load_cmd} & \pageref{load_cmd} \\
+ \hline
+ Error: Unable to build PCB & {\tt load} & \ref{load_cmd} & \pageref{load_cmd} \\
+ \hline
+ No process named $x$ & {\tt resume} & \ref{resume_cmd} & \pageref{resume_cmd} \\
+ \hline
+ Error: process did not load correctly & {\tt run} & \ref{run_cmd} & \pageref{run_cmd} \\
+ \hline
+ No process with the specified name & {\tt suspend} & \ref{suspend_cmd} & \pageref{suspend_cmd} \\
+ \hline
+ No process with the specified name & {\tt terminate} & \ref{terminate_cmd} & \pageref{terminate_cmd} \\
+ \hline
+ Error: invalid priority & {\tt setpriority} & \ref{setpriority_cmd} & \pageref{setpriority_cmd} \\
+ \hline
+ Error: invalid process name. & {\tt setpriority} & \ref{setpriority_cmd} & \pageref{setpriority_cmd} \\
+ \hline
+ Error setting clock & {\tt clock} & \ref{clock_cmd} & \pageref{clock_cmd} \\
+ \hline
+\end{tabular} \ No newline at end of file