Department of Computer Science
The University of Chicago
Last modified: Mon Feb 26 11:40:40 CST 2001
NACHOS Source Code
Most of what you learn in this class you will learn by reading and
modifying NACHOS source code. You need to become very
familiar with the structure of that code, as early as possible. I
haven't figured it out entirely myself, but I've noticed a few
important points.
- The Makefiles are to be designed to help organize
the projects. They work with gmake, rather than
make. Use these Makefiles all the time: don't
even think of issuing your own compiler commands.
- In order for the Makefiles to work properly, you need
to use exactly the directory structure in which the source is now
stored. To display that directory structure, I have provided a
direct view of the files, as well as a more conceptually organized
HTML presentation (under construction). You may also get at the
source files directly through UNIX on the CS instructional system,
outside of any WWW browser, at the path
/usr/local/classes/current/CS230/01/Nachos/nachos-3.4/code.
- The code directories appear to be organized, not according to
the structure of the operating system, but according to the
projects. Since these projects correspond fairly well to natural
modules of the OS, that's not too bad for readability. But, some
of the basic files are in the threads directory, not
because they deal especially with threads/processes, but because
the first project is concerned with threads. I am
building an alternate HTML web displaying the OS structure more
directly. Please post any errors that you discover in my
organization to the online discussion immediately.
- To complete your project work, you are allowed to change OS
code, but not MIPS simulator code. All of the latter
appears to be in the directory code/machine. Do not
change any file in
code/machine. code/threads/switch.s and
code/threads/swtch.s contain machine-dependent code for
context-switching. For your own peace of mind, don't change
these either.
Guide to Reading the Source Code
Source Code
System Utilities
- Debugging flags, ASSERT, miscellaneous arithmetic
-
- code/threads/utility.h
- code/threads/utility.cc
- List manipulation
-
- code/threads/list.h
- code/threads/list.cc
- Bitmap manipulation
- User address spaces are bitmaps.
- code/userprog/bitmap.h
- code/userprog/bitmap.cc
Basic System Code
- Bootstrap the kernel
-
- code/threads/main.cc
- Global system data, initialization, cleanup
-
- code/threads/system.h
- code/threads/system.cc
Threads
- Representation of thread, fork, finish, yield, sleep operations
-
- code/threads/thread.h
- code/threads/thread.cc
- Scheduler for threads
-
- code/threads/scheduler.h
- code/threads/scheduler.cc
- Context switch
-
- code/threads/switch.h
- code/threads/switch.s
(machine-dependent, do not modify)
- Synchronization primitives (semaphores, locks, condition
variables)
-
- code/threads/synch.h
- code/threads/synch.cc
- code/threads/synch.h-alt1
(ConditionVariables revised by Mike O'D)
- code/threads/synch.cc-alt1
(ConditionVariables revised by Mike O'D)
- code/threads/synch.cc-alt2
(Exchanger implemented with condition
variables by Mike O'D.)
- Synchronized list access
-
- code/threads/synchlist.h
- code/threads/synchlist.cc
- code/threads/synchlist.cc-alt1
(ConditionVariables revised by Mike O'D)
- Test program: two threads alternating
- This test is executed by the system from the
main function in
code/threads/main.cc. It is not a user program.
- code/threads/threadtest.cc
- Test program: readers and writers with bounded buffer,
by Mike O'D.
- This test is intended to be executed by the system from the
main function in
code/threads/main.cc. In order to run it that
way, you must make a small and obvious change to
main. In order to compile it with the
gmake command, you must modify
code/threads/Makefile and
code/Makefile.common. Use the treatment of
threadtest.o/threadtest.cc as a
model, and do the same things to
buffertest.o/buffertest.cc.
- code/threads/buffertest.cc
- Test program: communication channel, by Mike O'D.
- Analogous to the reader/writer test above.
- code/threads/channeltest.cc
- Test program: channel-buffer cycle, by Mike O'D.
- Analogous to the reader/writer test above.
- code/threads/chanbuftest.cc
User programs
- Manage user address space
-
- code/userprog/addrspace.h
- code/userprog/addrspace.cc
- Enter System from User Program (system call, exception,
interrupt)
-
- code/userprog/syscall.h
- code/userprog/exception.cc
- Test programs: run user program or test console
- One of the test functions StartProcess or
ConsoleTest is executed by the system from the
main function in code/threads.main.cc.
- code/userprog/progtest.cc
File System
- General operations
-
- code/filesys/filesys.h
- code/filesys/filesys.cc
- Directory management
-
- code/filesys/directory.h
- code/filesys/directory.cc
- Open file management
-
- code/filesys/openfile.h
- code/filesys/openfile.cc
- Synchronous disk access
-
- code/filesys/synchdisk.h
- code/filesys/synchdisk.cc
- Disk file header
-
- code/filesys/filehdr.h
- code/filesys/filehdr.cc
- Test program for file system assignment
-
- code/filesys/fstest.cc
Networking
These appear to be utilities for testing/debugging
User programs for testing
MIPS Simulator (do not modify)
Makefiles
code/Makefile
code/Makefile.common
code/Makefile.dep
code/threads/Makefile
code/userprog/Makefile
code/vm/Makefile
code/filesys/Makefile
code/network/Makefile
code/bin/Makefile
code/test/Makefile
Direct access to all the directories and files
(~odonnell/WWW/OData/Courses/CS230/NACHOS/code)