Question: on an unmodified Nachos is the halt program. When you are in the code directory and type make , the programs in the test directory
on an unmodified Nachos is the halt program. When you are in the code directory and type make
the programs in the test directory are cross compiled and executable Nachos user applications are
created. Check out the test directory and note the source files such as halt.c with their
corresponding executables such as halt Then go to the userprog directory. Nachos should have
been built already ie there is a nachos executable in this directory If not, type make nachos
Then, type nachos x testhalt This will start Nachos and ask it to load and run
the halt program. You should see a message indicating that Nachos is halting at the request of the
user program.
In brief, what happens when you type nachos x halt is as follows:
Nachos starts. The initial thread starts by running function StartProcess in file progtest.cc
A new address space is allocated for the user process, and the contents of the executable
file halt are loaded into that address space. This is accomplished by the constructor
function AddrSpace::AddrSpace in the file addrspace.cc called from StartProcess
MIPS registers and memory management hardware are initialised for the new user process by
the functions AddrSpace::InitRegister and AddrSpace::RestoreState in addrspace.cc
Control is transferred to user mode and the halt program begins running. This is accomplished
by the function Machine::Run in machinemipssimcc which starts the MIPS emulator.
The system call Halt is executed from user mode now running the program halt This
causes a trap back to the Nachos kernel via function ExceptionHandler in file exception.cc
The exception handler determines that a Halt system call was requested from user mode,
and it halts Nachos by calling the function Interrupt::Halt in machineinterruptcc
Trace through the Nachos code until you think you understand how program halt is executed.
In this assignment, you will also need to know the object file formats for Nachos. This is how NOFF
Nachos Object File Format looks like.
bss segment data segment code segment
header
Noffformat files consist of four parts. The first part, the Noff header, describes the contents of the
rest of the file, giving information about the program's instructions code segment initialised
variables data segment and uninitialised variables bss segment
The Noff header resides at the very start of the file and contains pointers to the remaining sections.
Specifically, the Noff header contains
magic xbadfad For each of the three segments
virtual addr points to the location in virtual memory in f
ile addr points to a location within the NOFF file where section begins
size size of the segment in bytes
This information about the NOFF can be found in binnoffh file.
When you create user programs and compile them using the MIPS compiler cross compile you get
COFF common object file format files. This is a normal MIPS object executable For this file to be
runnable under Nachos, it has to be turned into NOFF. This is done by using bincoffnoff the
COFF to NOFF translator. Please check the Makefile in codetest directory to see how is this done.
You will need to add code in start.s and userprogsyscallh in order to add a new system call Kill
Exercises
You are to implement the Fork Yield Exit Exec Kill and Join system calls. The
function prototypes of the system calls are listed in syscall.h and act as follows:
The Forkfunc system call creates a new user
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
