120 likes | 267 Views
Instructions to Project 2. Tingxin Yan 3/9/2011. Goal of the project. Previous project Implemented some kernel functions of an OS. This project provide Nachos with support for multi-programming at the user level.
E N D
Instructions to Project 2 Tingxin Yan 3/9/2011
Goal of the project • Previous project • Implemented some kernel functions of an OS. • This project • provide Nachos with support for multi-programming at the user level. • allow user-level programs to access some of kernel routines via system calls. • Example: A Terminal.
Steps • Install MIPS Cross-compiler for Nachos. • Read and understand the part of the system that has been written for you. • Write your own implementations and test cases.
Install MIPS Cross-compiler • Supported OS: • Windows+Cygwin • Linux • MacOS(PPC) (Sorry new Macbook Pros…) • You can build your own…
Install MIPS Cross-compiler • Download mips cross-compiler tar ball. • Unzip to your destination directory • Say, /home/XYZ/mips-xgcc • Setup environment export ARCHDIR=/home/XYZ/mips-xgcc export PATH=$ARCHDIR:$PATH • Edit .bashrc (or .bash_profile) to make effect.
Test if MIPS Cross-compiler is working • Under nachos/test • Type make • Undernachos/proj2 • Type make • Type ../bin/nachos
Understand the System • nachos.userprog package • UserKernel.java - a multiprogramming kernel. • Similar to ThreadedKernel.javain threads. • UserProcess.java - a user process; manages the address space, and loads a program into virtual memory. • UThread.java - a thread capable of executing user MIPS code. • SynchConsole.java - a synchronized console; makes it possible to share the machine's serial console among multiple threads.
Understand the System • a few additional machine simulation classes that get used • machine.Processor.java: simulate a MIPS processor. • machine.SerialConsole.java: simulate a serial console for keyboard input and text output. • machine.FileSystem.java: a file system interface. This file system accesses files in the test directory.
User Programs • Under nachos/test • C programs. • You need to write your test cases in C. • Compiled to .coff binaries, which are real Nachos user programs.
Running Process of a User Program • Source files (*.c) are compiled into object files (*.o) by mips-gcc. • Some of the object files are linked into libnachos.a, the Nachos standard library. • start.s is preprocessed and assembled into start.o. This file contains the assembly-language code to initialize a process. It also provides the system call "stub code" which allows system calls to be invoked. This makes use of the special MIPS instruction syscall which traps to the Nachos kernel to invoke a system call. • An object file is linked with libnachos.a to produce a Nachos-compatible MIPS binary, which has the extension *.coff. (COFF stands for Common Object File Format and is an industry-standard binary format which the Nachos kernel understands.)
What you need to do • Implement file system calls • create, open, read, write, close, and unlink • Implement support for multiprogramming • Now one user program at a time. • Implement some other system calls • exec, join, and exit
What you need to do • Modify nachos.userprog package. • UserProcess.java+ UserKernel.java • Add test cases in nachos.test • The easiest way to compile your own test cases is to add it to the Makefile in the test directory in the line: TARGETS = halt shmatmalt sort echo cat cp mvrm #chat chatserver • Run user programs • Under proj2, type nachos –x [PROGNAME].coff