1 / 27

Nachos Project 1: Adding New System Calls

Learn how to add new system calls in the Nachos environment, familiarize yourself with the Nachos system, and implement new system calls in this project.

wfulton
Download Presentation

Nachos Project 1: Adding New System Calls

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 342302 OPERATING SYSTEMS Nachos Project 1 Start-up and System call

  2. MOTIVATION • System calls are the interfaces that user programs can ask services from kernel. • How to add a new system call is very essential.

  3. OBJECTIVE • Be familiar with the Nachos environment. • Design and implement new system calls in this project.

  4. PLATFORM • Use Linux on our server. • You could also build up your Linux environment by yourself.

  5. LOGIN • Download pietty (http://ntu.csie.org/~piaip/pietty/) • Server IP : 140.114.71.238

  6. LOGIN • Both the account name and the default password are “os”+your student number. (ex. os9862518) • After you login, you must change your password. (use passwd command) • $passwd

  7. BASIC COMMAND • NOTE : Some basic commands you have to know:for example : $cd <directory> : enter directory $cd .. : go back to upper directory $cd ~ : enter home directory $ctrl + c : process termination good place : 鳥哥的 Linux 私房菜 (http://linux.vbird.org/)

  8. COMPLETE YOUR NACHOS ENVIRONMENT • Enter your home directory $ cd ~ • We have already prepared for you • nachos-java.tar.gz , nachos-java.tar.gz • Decompress it! $ tar zxvf nachos-java.tar.gz $ tar zxvf mips-x86.linux-xgcc.tgz • Enter the nachos/test directory and execute make. If there is no errors, your MIPS cross compiler environment is set correctly. $ cd /nachos/test $ make

  9. MAKE RESULT • Note: If there are errors when you make, contact TA please. Otherwise, you couldn’t complete this project

  10. EXECUTE NACHOS • Go back and enter the proj1 directory and execute make. It will create the directory named nachos. Finally, execute nachos to run Nachos, you will see some lines of messages when running. $ cd .. $ cd proj1 $ make $ nachos

  11. RUNNING RESULT • If there is no error so far, your Nachos environment is set successfully.

  12. HOW TO MODIFY • Use vim on the server (suggested) Reference : http://www.study-area.org/tips/vim/ http://linux.vbird.org/linux_basic/0310vi.php • Or you can use the FTP software (ex. FileZilla) with SSH (port:22) to download and upload the file which have to be modify, then you can use your own editor in your operating system.

  13. BASIC REQUIREMENTIMPLEMENT & ADD THE FOLLOWING SYSTEM CALL: • int add(int op1, int op2); • int pow(int op1, int op2); • void print(char *msg); • void print2(char *msg, int value); You only need to parse the parameter %d. • void exit(int status); In order to terminate user programs properly.

  14. RELATED CODE FOR USER PROCESSES • ~/nachos/test/start.S Startup assembly code for every user program of Nachos. • ~/nachos/test/syscall.h Definitions of the system call prototypes • ~/nachos/userprog/UserProcess.java Encapsulates the state of a user process, including the handler for system calls and other exceptions.

  15. ADD YOUR SYSTEM CAL • Declare a new system call in test/syscall.h - Define a new system call ID E.g., #define syscallAdd 13 - Declare the interface for Nachos system calls, which will be called by the user program. E.g., int add(int op1, int op2); • Add the low level operation to support the new declared system call in test/start.S E.g., SYSCALLSTUB(add, syscallAdd)

  16. ADD YOUR SYSTEM CALL • handleSyscall in userprog/UserProcess.java 1. Define system call ID which you’ve defined in UserProcess.java private static final int syscallHalt = 0, ….. 2. Write your system call in the switch case public int handleSyscall (int syscall, int a0, int a1, int a2, int a3) { switch (syscall) { case syscallAdd: return a0+a1; …..

  17. ADD YOUR PROGRAM • You have to run the following test program onyour Nachos.

  18. ADD YOUR PROGRAM(CONT.) • If you call the test file “proj1.c”. • First, put the file under /test, and modify the file “Makefile”. TARGETS = halt sh matmult sort echo cat cp mv rm #chat chatserver  TARGETS = halt sh matmult sort echo cat cp mv rm proj1 #chat chatserver • then “make” again under the /test directory. • If appear “make: Nothing to be done for `all'.” • $ make clean • $ make

  19. RUN YOUR PROGRAM • In file ~/nachos/proj2 • Then modify the line 12 of /proj2/nachos.conf Kernel.shellProgram = halt.coff #sh.coff  Kernel.shellProgram = proj1.coff #sh.coff • “make” under /proj2. • Enter “nachos” to run it.

  20. RESULT

  21. HINT • In system call “print” and “print2” may use the functions below: readVirtualMemoryString(); System.out.println(); try to know how to use it

  22. SUBMISSION & GRADING POLICY • Code correctness 65% • Every system call is 13% • Readability 5% • Report 30% • Bonus 10%

  23. BONUS • Anything different from Basic Requirement • Build your own nachos' environment • For example : • Using Vmware, install Ubuntu, nachos, mips …etc. • Another system call • For example : • Create, open, write, read …etc.

  24. REPORT REQUIREMENT • Free but basically • What problem have you met and how to solve it • What have you learned from this project • Your bonus part (if have, Explain it in detail) • Score & Detail (in direct ratio)

  25. DEADLINE • 2009 / 10 / 21 ( 23:59 pm)

  26. office hour : • 週一 (Mon) : 7:00pm~10:00pm 綜二 751

  27. REFERENCES • 鳥哥的 Linux 私房菜 • Linux 基本操作

More Related