CS 342302 OPERATING SYSTEMS Nachos Project 1 Startup

  • Slides: 28
Download presentation
CS 342302 OPERATING SYSTEMS Nachos Project 1 Start-up and System call

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

MOTIVATION System calls are the interfaces that user programs can ask services from kernel.

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

OBJECTIVE Be familiar with the Nachos environment. Design and implement new system calls in

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

PLATFORM Use Linux on our server. You could also build up your Linux environment

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

LOGIN Download pietty (http: //ntu. csie. org/~piaip/pietty/) Server IP : 140. 114. 71. 238

LOGIN Download pietty (http: //ntu. csie. org/~piaip/pietty/) Server IP : 140. 114. 71. 238 PORT : 35568 需更改

LOGIN Both the account name and the default password are “os”+your student number. (ex.

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

BASIC COMMAND NOTE : Some basic commands you have to know: for example :

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/)

COMPLETE YOUR NACHOS ENVIRONMENT Enter your home directory $ cd ~ We have already

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-x 86. 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

MAKE RESULT Note: If there are errors when you make, contact TA please. Otherwise,

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

EXECUTE NACHOS Go back and enter the proj 1 directory and execute make. It

EXECUTE NACHOS Go back and enter the proj 1 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 proj 1 $ make $ nachos

RUNNING RESULT If there is no error so far, your Nachos environment is set

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

HOW TO MODIFY Use vim on the server (suggested) Reference : http: //www. study-area.

HOW TO MODIFY Use vim on the server (suggested) Reference : http: //www. study-area. org/tips/vim/ http: //linux. vbird. org/linux_basic/0310 vi. php Or you can use the FTP software (ex. File. Zilla) 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.

BASIC REQUIREMENT IMPLEMENT & ADD THE FOLLOWING SYSTEM CALL: int add(int op 1, int

BASIC REQUIREMENT IMPLEMENT & ADD THE FOLLOWING SYSTEM CALL: int add(int op 1, int op 2); int pow(int op 1, int op 2); void print(char *msg); void print 2(char *msg, int value); You only need to parse the parameter %d. void exit(int status); In order to terminate user programs properly.

RELATED CODE FOR USER PROCESSES ~/nachos/test/start. S Startup assembly code for every user program

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/User. Process. java Encapsulates the state of a user process, including the handler for system calls and other exceptions.

ADD YOUR SYSTEM CAL Declare a new system call in test/syscall. h - Define

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

ADD YOUR SYSTEM CALL handle. Syscall in userprog/User. Process. java 1. Define system call

ADD YOUR SYSTEM CALL handle. Syscall in userprog/User. Process. java 1. Define system call ID which you’ve defined in User. Process. java private static final int syscall. Halt = 0, …. . 2. Write your system call in the switch case public int handle. Syscall (int syscall, int a 0, int a 1, int a 2, int a 3) { switch (syscall) { case syscall. Add: return a 0+a 1; …. .

ADD YOUR PROGRAM You have to run the following test program on your Nachos.

ADD YOUR PROGRAM You have to run the following test program on your Nachos.

ADD YOUR PROGRAM(CONT. ) If you call the test file “proj 1. c”. First,

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

RUN YOUR PROGRAM In file ~/nachos/proj 2 Then modify the line 12 of /proj

RUN YOUR PROGRAM In file ~/nachos/proj 2 Then modify the line 12 of /proj 2/nachos. conf Kernel. shell. Program = halt. coff #sh. coff Kernel. shell. Program = proj 1. coff #sh. coff “make” under /proj 2. Enter “nachos” to run it.

RESULT

RESULT

HINT In system call “print” and “print 2” may use the functions below: read.

HINT In system call “print” and “print 2” may use the functions below: read. Virtual. Memory. String(); System. out. println(); try to know how to use it

SUBMISSION & GRADING POLICY Code correctness 65% Every system call is 13% Readability 5%

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

BONUS Anything different from Basic Requirement Build your own nachos' environment For example :

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.

REPORT REQUIREMENT Free but basically What problem have you met and how to solve

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) 報告越詳細分數越高

DEADLINE 2009 / 10 / 21 ( 23: 59 pm)

DEADLINE 2009 / 10 / 21 ( 23: 59 pm)

OFFICE HOUR : 週一 (Mon) : 7: 00 pm~10: 00 pm 綜二 751

OFFICE HOUR : 週一 (Mon) : 7: 00 pm~10: 00 pm 綜二 751

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

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