Not Another Completely Heuristic Operating System, or Nachos, is instructional software for teaching undergraduate, and potentially graduate level operating systems courses. It was developed at the University of California, Berkeley, designed by Thomas Anderson, and is used by numerous schools around the world.
In Makefile.common
# The dependency graph between assignments is:
# 1. THREADS before everything else
# 2. USERPROG must come before VM
# 3. USERPROG can come before or after FILESYS, but if USERPROG comes
# before (as in this distribution), then it must define FILESYS_STUB
#
# Other than that, you have complete flexibility.
Makefiles
- Makefile
- Makefile.common
- Makefile.dep
Folder
- bin: for MIPS interpreter (coff2noff)
- machine: for MIPS environment simulation
- threads: main and threads
- userprog: user program, system call and exception
- test: some user program test
- filesys: file system
- network
- vm
nachos
: one for each compile (subdirectory "machines" which with different define/macro settings)coff2noff
: converting a COFF (Common Object File Format) file to a NOFF file (Nachos Object File Format)
For more detail checkout here
Nachos runs user programs in their own private address space. Nachos can run any MIPS binary.
In Unix, "a.out" files are stored in "coff" format. Nachos requires that executables be in the simpler "Noff" format.
Use the coff2noff
program to convert binary. Consult the code/test/Makefile
for details.
When executing a program, Nachos
- creates an address space
- copies the contents of the instruction
- initialized variable segments into the address space
- (the uninitialized variable section doesn't need to be read from the file, since it is defined to contain all zeros)
Noff-format files consist of four parts
- Noff header
- describes the contents of the rest of the file
- giving information about the program's instruction, initialized variables and uninitialized variables
Noff header resides at the very start of the file. And containes pointers to the remaining section.
- noffMagic: a reserved "magic" number that indicates that the file is in Noff format. (first 4 bytes of the file)
- virtualAddr: what virtual address that segment begins at (normally zero)
- inFileAddr: pointer within the Noff file where that section actuall begins (so that Nachos can read it into memory before execution begins)
- size:the size (in bytes of that segment)
The -d
argument
nachos -d <debug_flag>
code/lib/debug.h
(does not exist in current version Nachos code, but the flags are the same)// The pre-defined debugging flags are: const char dbgAll = '+'; // turn on all debug messages const char dbgThread = 't'; // threads const char dbgSynch = 's'; // locks, semaphores, condition vars const char dbgInt = 'i'; // interrupt emulation const char dbgMach = 'm'; // machine emulation (USER_PROGRAM) const char dbgDisk = 'd'; // disk emulation (FILESYS) const char dbgFile = 'f'; // file system (FILESYS) const char dbgAddr = 'a'; // address spaces (USER_PROGRAM) const char dbgNet = 'n'; // network emulation (NETWORK)
The debug flag is defined in code/threads/utility.h
// The debugging routines allow the user to turn on selected
// debugging messages, controllable from the command line arguments
// passed to Nachos (-d). You are encouraged to add your own
// debugging flags. The pre-defined debugging flags are:
//
// '+' -- turn on all debug messages
// 't' -- thread system
// 's' -- semaphores, locks, and conditions
// 'i' -- interrupt emulation
// 'm' -- machine emulation (USER_PROGRAM)
// 'd' -- disk emulation (FILESYS)
// 'f' -- file system (FILESYS)
// 'a' -- address spaces (USER_PROGRAM)
// 'n' -- network emulation (NETWORK)
...
extern void DEBUG (char flag, char* format, ...); // Print debug message
// if flag is enabled
I've add
c
for (random) Context Switch used inthreads/system.cc
. I've addb
for Barrier related inthreads/synch.cc
I've addw
for Reader-Writer Lock related inthreads/synch.cc
I've addT
for TLB handling inmachine/exception.cc
I've addM
for memory management (allocation, data structure (e.g. bitmap)) inmachine/machine.cc
I've addS
for system call inmachine/exception.cc
I've addD
for multi-level directory infilesys/filesys.cc
The -s
argument
ASSERT()
gdb nachos
- Washington Nachos (Official Website)
- Nachos Beginner's Guide - Nachos support documentation
- Nachos Introduction Slides
- NYU Nachos Resources
- Nachos Overview
- CS 1550 Nachos
- NachOS安裝心得
Developed originally at U.C., Berkeley.
- CS162: Operating Systems and Systems Programming
- Book Reading
- Operating Systems: Principles and Practice 2nd Edition (Required)
- Operating System Concepts 9th Edition (Recommended)
- Understanding the Linux Kernel, Third Edition (Supplemental)
- Linux Kernel Development 3rd Edition (Supplemental)
- Semester archives
- CS162 Spring 2005
- CS162 Spring 2007 Phases - Using Java
- Book Reading
Goal
- Implement system calls for Read, Write, Exit, Join, Exec, etc.
- Implement vitual memory so that multiple programs can be in memory at the same time.
- Implement paging so that Mips physical memory limitations don't limit the number or size of the Mips user programs that can execute concurrently.
- CPS 110 / EE 153 Operating Systems - Y2K spring
- Nachos Project Guide
- Nachos Lab Assignments
- Lab 1: The Trouble with Concurrent Programming
- Lab 2: Threads and Synchronization
- Lab 3: Programming with Threads
- Lab 4: Multiprogrammed Kernel
- Lab 5: I/O
- Lab 6: Virtual Memory
- Nachos Lab Assignments
- Nachos Project Guide