ECE469 Spring 2004 Laboratory #1
The purpose of this lab is to get you started with DLXOS,
the mini-OS used in course projects, and to teach you
how system calls are implemented, the understanding of which
is essential in doing the rest of the projects.
Specifically, we will cover the following three topics:
- Setting up DLXOS
- Tutorial on context switch, system stack frames, and the implementation of trap
- Implementation of system call getpid()
1. DLXOS
The projects for this course require you to build a real
operating system and then to experiment with it. Our base is
a very simple, but functional, operating system called
DLXOS. The system was written at the University of Maryland
Baltimore County and the University of California, Santa
Cruz, and is based on the DLX instruction set architecture
described by Hennessy & Patterson. Over the course of the
semesterd, your job will be to improve the functionality and
performance of DLXOS.
As much as possible, the assignments are structured so that
you will be able to finish the project even if not all of
the pieces you have built are working, but you will get more
out of the project if you use your own code. An interesting
aspect of building this operating system is that you get to
use what you build; if you do a good job in designing and
implementing the early phases of the project, it will
simplify your task in building the later phases.
It's important to realize that while you run DLXOS on top of
this simulation as a user program on UNIX, all of the code
you write is exactly the same as if DLXOS were running on
bare hardware. The simulator runs as a user program for
convenience: multiple students can run DLXOS at the same
time on the same physical machine. These same reasons apply
in industry it's usually a good idea to test out
system code in a simulated environment before running it on
potentially flaky hardware. In real life, you are not
allowed to throw out a running machine and ask for a CPU
with different features before your code will work.
Home Page of DLXOS
The home page of DLXOS is at
DLXOS.
Note the
DLX simulator
contains changes to the basic DLX architecture that
are related to operating system support. For more information on DLX instruction set, please refer to the following
DLX instruction
set.
Setting up DLXOS
Do as below in your home directory:
log onto a Linux machine (dlxos does not compile on Sun machines)
mkdir -p ~/ee469/dlxos
cp /home/shay/g/ee469/labs/common/dlxos.tar.gz ~/ee469/dlxos
cd ~/ee469/dlxos
gunzip dlxos.tar.gz
tar xvf dlxos.tar
add the line below at the end of your ~/.cshrc to include DLX compiler
and assembler,
set path = (/home/shay/g/ee469/labs/common/dlxos/bin $path)
type "source ~/.cshrc" at the prompt.
To compile, type "make" in ~/ee469/dlxos/src/ directory.
To run, type "dlxsim -x os.dlx.obj" in ~/ee469/dlxos/execs/ directory.
To load a user program for the OS, type "dlxsim -x os.dlx.obj -a -u userprog.dlx.obj" in ~/ee469/dlxos/execs/ directory. Make sure you copy the userprog.dlx.obj to the execs first. look at the Makefile to see how to make the userprog.dlx.obj. Also, to test the user program comment out the ProccessFork calls in the funtion SysprocCreateProcesses () in sysproc.c
For more information about using dlxsim, please refer to
dlxsim_help.html.
For more information about using built-in debugging flags in dlxos,
please refer to dlxos_debug.html.
Major components in ~/ee469/dlxos/src/
process.c : routines dealing with processes and the "main" routine for the OS which
creates the initial process.
synch.c : routines for synchronizations.
memory.c : routines for memory management.
filesys.c : basic routines for the simulator-provided file systems.
traps.c : handles the low-level trap stuff for an operating system running under DLX.
sysproc.c : defines system processes run by the OS such as initialize system process.
queue.c : basic routines implementing a queue which you may need for your assignments.
2. Tutorial on System Stack in DLXOS (pdf)
3. How to support a new trap in DLXOS?
To understand how trap works in DLXOS, you need to read and understand at least
the following files: process.h, dlxos.s, usertraps.s, process.c.
If you are unfaimilar with the DLX instruction set architecture,
there are abundant tutorials online, do a google search on "DLX ISA"
or "DLX ISA tutorial".
The procedure for adding a new trap to DLXOS is as follows:
(1) Find a new trap vector.
Open the traps.h, you can see a lot of trap vectors.
You can create one for you own,
e.g. #define TRAP_PROCESS_FORK 0x430
(2) In usertraps.s, you need to provide the user trap interface,
e.g.
.proc _fork
.global _fork
_fork:
trap #0x430 ; the vector you defined above
nop
jr r31
nop
.endproc _fork
(3) Once the user call fork(), the architectural simulator
will execute the trap instruction and transfer the control
to _intrhandler in dlxos.s
Please read the handler to understand the major steps of
pushing stacks and etc.
(4) Last, you need to create the trap handler for fork().
Please read dointerrupt() in traps.c and figure out
how user parameters are popped and processed. At this point,
we are in kernel mode.
4. Assignments
Augment process.h and process.c to implement the system calls getpid().
Synopsis: unsigned getpid(void);
(You can also use the man page on Linux: "man getpid".)
Description: getpid() returns the identity which the OS associates upon creation.
ee469@shay
Back