Presentation is loading. Please wait.

Presentation is loading. Please wait.

Nachos Project 1 Start-up and System call

Similar presentations


Presentation on theme: "Nachos Project 1 Start-up and System call"— Presentation transcript:

1 Nachos Project 1 Start-up and System call
CS 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 : PORT : 35568 需更改

6 LOGIN 如出現以下畫面 選 “是(Y)”

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

8 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 私房菜 (

9 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

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

11 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

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

13 HOW TO MODIFY Use vim on the server (suggested)
Reference : 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.

14 BASIC REQUIREMENT IMPLEMENT & 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.

15 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.

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

17 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;

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

19 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

20 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.

21 RESULT

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

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

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

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

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

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

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


Download ppt "Nachos Project 1 Start-up and System call"

Similar presentations


Ads by Google