cs 342302 operating systems nachos project 1 start-up and system call

Post on 28-Dec-2015

237 Views

Category:

Documents

6 Downloads

Preview:

Click to see full reader

TRANSCRIPT

CS 342302 OPERATING SYSTEMSNachos Project 1

Start-up and System call

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

this project.

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 PORT : 35568

需更改

LOGIN

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

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

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

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

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

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.

RELATED CODE FOR USER PROCESSES

~/nachos/test/start.SStartup assembly code for every user program of Nachos.

~/nachos/test/syscall.hDefinitions of the system call prototypes

~/nachos/userprog/UserProcess.javaEncapsulates 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 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)

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;

…..

ADD YOUR SYSTEM CALL

ADD YOUR PROGRAM

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

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

RUN YOUR PROGRAM

In file ~/nachos/proj2 Then modify the line 12 of /proj2/nachos.conf

Kernel.shellProgram = halt.coff #sh.coffKernel.shellProgram = proj1.coff #sh.coff

“make” under /proj2. Enter “nachos” to run it.

RESULT

HINT

In system call “print” and “print2” may use the functions below:

readVirtualMemoryString();System.out.println();

try to know how to use it

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 : 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 it What have you learned from this project Your bonus part (if have, Explain it in detail) 報告越詳細分數越高

DEADLINE

2009 / 10 / 21 ( 23:59 pm)

OFFICE HOUR :

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

REFERENCES

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

top related