0% found this document useful (0 votes)
56 views

Network Directory Has Been Removed: - For HP Workstations (Aegis, Intrepid) - Recommended

Nachos is an instructional operating system developed at UC Berkeley to teach operating system concepts. It consists of an OS and a machine emulator. The OS code is organized into directories like threads and filesys. The machine emulator simulates CPU registers, memory, and devices. The document provides instructions for students to read background materials on Nachos and look at the OS and emulator code to prepare for their first programming project.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

Network Directory Has Been Removed: - For HP Workstations (Aegis, Intrepid) - Recommended

Nachos is an instructional operating system developed at UC Berkeley to teach operating system concepts. It consists of an OS and a machine emulator. The OS code is organized into directories like threads and filesys. The machine emulator simulates CPU registers, memory, and devices. The document provides instructions for students to read background materials on Nachos and look at the OS and emulator code to prepare for their first programming project.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Nachos Preparing for the First Project

n Nachos is an instructional operating n Reading assignment:


system developed at UC Berkeley ● Read about Nachos, & skim the material
on the emulated machine and threads
n Nachos consists of two main parts: n Don’t worry about synchronization, user
● Operating system programs, or the file system
n This is the part of the code that you will ● Read old Appendix A of the text (online
study and modify as “Overview Paper”)
n This code is in the threads, userprog,
and filesys directories ● Skim Section 2 “Nachos Machine” and
n We will not study networking, so the Section 3 “Nachos Threads” in Narten’s
network directory has been removed “A Road Map Through Nachos” (online)

● Machine emulator — simulates a (slightly ● Skim material on threads in Kalra’s “Salsa


old) MIPS CPU, registers, memory, timer — An OS Tutorial” (online)
(clock), console, disk drive, and network ● Start looking at the code in the threads
n You will study this code, but will not be and machine directories
allowed to modify it
n This code is in the machine directory ● Road Map plus printouts of all code are
available in the MCS office for $4.50
n The OS and machine emulator run
together as a single UNIX process n If you are not familiar with C++ or the gdb
debugger, see the class web page
1 Fall 1998, Lecture 09 2 Fall 1998, Lecture 09

Preparing for the First Project


Nachos — The Emulated Machine
(cont.)

n Compiling the code n Code is in the machine directory


● Nachos source code is available in
~walker/pub n machine.h, machine.cc — emulates the
part of the machine that executes user
● Read ~walker/pub/README programs: main memory, processor
● Decide where you want to work, so you registers, etc.
can copy files from the appropriate
directory into your account n mipssim.cc — emulates the integer
n ~walker/pub/nachos-3.4-hp instruction set of a MIPS R2/3000 CPU.
– For HP workstations (aegis, intrepid)
– Recommended n interrupt.h, interrupt.cc — manages
n ~walker/pub/nachos-3.4-sparc enabling and disabling interrupts as part
– For Sun workstations (nimitz)
of the machine emulation.
n ~walker/pub/nachos-3.4-orig
– The original, unmodified version
n timer.h, timer.cc — emulates a clock
● Read “Project 1 — Getting an Early Start” that periodically causes an interrupt to
on the class web page to find out how to occur.
copy the necessary files to your account,
and compile an executable copy of n stats.h — collects interesting statistics.
Nachos into the threads directory

3 Fall 1998, Lecture 09 4 Fall 1998, Lecture 09


Nachos — The Operating System Nachos Threads

n For now, we will mostly be concerned with n As distributed, Nachos does not support
code in the threads directory multiple processes, only threads
● All threads share / execute the same
n main.cc, threadtest.cc — a simple test of code (the Nachos source code)
the thread routines.
● All threads share the same global
n system.h, system.cc — Nachos variables (have to worry about synch.)
startup/shutdown routines.
n Some interesting functions:
n thread.h, thread.cc — thread data ● Thread::Fork( ) — create a new thread to
structures and thread operations such as run a specified function with a single
thread fork, thread sleep and thread finish. argument, and put it on the ready queue
● Thread::Yield( ) — if there are other
n scheduler.h, scheduler.cc — manages threads waiting to run, suspend this
the list of threads that are ready to run. thread and run another
● Thread::Sleep( ) — this thread is waiting
n list.h, list.cc — generic list management. on some event, so suspend it, and hope
someone else wakes it up later
n utility.h, utility.cc — some useful
definitions and debugging routines. ● Thread::Finish( ) — terminate the
currently running thread
5 Fall 1998, Lecture 09 6 Fall 1998, Lecture 09

Manipulating Threads in Nachos


Manipulating Threads in Nachos
(cont.)

void void
Thread::Fork(VoidFunctionPtr func, int arg) Thread::Yield ()
{ {
DEBUG('t',"Forking thread \"%s\" with Thread *nextThread;
func = 0x%x, arg = %d\n",
name, (int) func, arg); IntStatus oldLevel = interrupt->
SetLevel(IntOff);
StackAllocate(func, arg);
ASSERT(this == currentThread);
IntStatus oldLevel = interrupt-> DEBUG('t', "Yielding thread \"%s\"\n",
SetLevel(IntOff); getName());
scheduler->ReadyToRun(this);
(void) interrupt->SetLevel(oldLevel); nextThread = scheduler->
} FindNextToRun();
if (nextThread != NULL) {
scheduler->ReadyToRun(this);
scheduler->Run(nextThread);
}
(void) interrupt->SetLevel(oldLevel);
}
7 Fall 1998, Lecture 09 8 Fall 1998, Lecture 09
Manipulating Threads in Nachos
(cont.)

void
Thread::Sleep ()
{
Thread *nextThread;

ASSERT(this == currentThread);
ASSERT(interrupt->getLevel() == IntOff);
DEBUG('t', "Sleeping thread \"%s\"\n",
getName());

status = BLOCKED;
while ((nextThread = scheduler->
FindNextToRun()) == NULL)
interrupt->Idle();

scheduler->Run(nextThread);
}

9 Fall 1998, Lecture 09

You might also like