nachos.kernel.userprog
Class Syscall

java.lang.Object
  extended by nachos.kernel.userprog.Syscall

public class Syscall
extends java.lang.Object

Nachos system call interface. These are Nachos kernel operations that can be invoked from user programs, by trapping to the kernel via the "syscall" instruction.


Field Summary
static int ConsoleInput
          OpenFileId used for input from the keyboard.
static int ConsoleOutput
          OpenFileId used for output to the display.
static byte SC_Close
          Integer code identifying the "Close" system call.
static byte SC_Create
          Integer code identifying the "Create" system call.
static byte SC_Exec
          Integer code identifying the "Exec" system call.
static byte SC_Exit
          Integer code identifying the "Exit" system call.
static byte SC_Fork
          Integer code identifying the "Fork" system call.
static byte SC_Halt
          Integer code identifying the "Halt" system call.
static byte SC_Join
          Integer code identifying the "Join" system call.
static byte SC_Open
          Integer code identifying the "Open" system call.
static byte SC_Read
          Integer code identifying the "Read" system call.
static byte SC_Remove
          Integer code identifying the "Remove" system call.
static byte SC_Write
          Integer code identifying the "Write" system call.
static byte SC_Yield
          Integer code identifying the "Yield" system call.
 
Constructor Summary
Syscall()
           
 
Method Summary
static void close(int id)
          Close the file, we're done reading and writing to it.
static void create(java.lang.String name)
          Create a Nachos file with a specified name.
static int exec(java.lang.String name)
          Run the executable, stored in the Nachos file "name", and return the address space identifier.
static void exit(int status)
          This user program is done.
static void fork(int func)
          Fork a thread to run a procedure ("func") in the *same* address space as the current thread.
static void halt()
          Stop Nachos, and print out performance stats.
static int join(int id)
          Wait for the user program specified by "id" to finish, and return its exit status.
static int open(java.lang.String name)
          Open the Nachos file "name", and return an "OpenFileId" that can be used to read and write to the file.
static int read(byte[] buffer, int size, int id)
          Read "size" bytes from the open file into "buffer".
static void remove(java.lang.String name)
          Remove a Nachos file.
static void write(byte[] buffer, int size, int id)
          Write "size" bytes from "buffer" to the open file.
static void yield()
          Yield the CPU to another runnable thread, whether in this address space or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SC_Halt

public static final byte SC_Halt
Integer code identifying the "Halt" system call.

See Also:
Constant Field Values

SC_Exit

public static final byte SC_Exit
Integer code identifying the "Exit" system call.

See Also:
Constant Field Values

SC_Exec

public static final byte SC_Exec
Integer code identifying the "Exec" system call.

See Also:
Constant Field Values

SC_Join

public static final byte SC_Join
Integer code identifying the "Join" system call.

See Also:
Constant Field Values

SC_Create

public static final byte SC_Create
Integer code identifying the "Create" system call.

See Also:
Constant Field Values

SC_Open

public static final byte SC_Open
Integer code identifying the "Open" system call.

See Also:
Constant Field Values

SC_Read

public static final byte SC_Read
Integer code identifying the "Read" system call.

See Also:
Constant Field Values

SC_Write

public static final byte SC_Write
Integer code identifying the "Write" system call.

See Also:
Constant Field Values

SC_Close

public static final byte SC_Close
Integer code identifying the "Close" system call.

See Also:
Constant Field Values

SC_Fork

public static final byte SC_Fork
Integer code identifying the "Fork" system call.

See Also:
Constant Field Values

SC_Yield

public static final byte SC_Yield
Integer code identifying the "Yield" system call.

See Also:
Constant Field Values

SC_Remove

public static final byte SC_Remove
Integer code identifying the "Remove" system call.

See Also:
Constant Field Values

ConsoleInput

public static final int ConsoleInput
OpenFileId used for input from the keyboard.

See Also:
Constant Field Values

ConsoleOutput

public static final int ConsoleOutput
OpenFileId used for output to the display.

See Also:
Constant Field Values
Constructor Detail

Syscall

public Syscall()
Method Detail

halt

public static void halt()
Stop Nachos, and print out performance stats.


exit

public static void exit(int status)
This user program is done.

Parameters:
status - Status code to pass to processes doing a Join(). status = 0 means the program exited normally.

exec

public static int exec(java.lang.String name)
Run the executable, stored in the Nachos file "name", and return the address space identifier.

Parameters:
name - The name of the file to execute.

join

public static int join(int id)
Wait for the user program specified by "id" to finish, and return its exit status.

Parameters:
id - The "space ID" of the program to wait for.
Returns:
the exit status of the specified program.

create

public static void create(java.lang.String name)
Create a Nachos file with a specified name.

Parameters:
name - The name of the file to be created.

remove

public static void remove(java.lang.String name)
Remove a Nachos file.

Parameters:
name - The name of the file to be removed.

open

public static int open(java.lang.String name)
Open the Nachos file "name", and return an "OpenFileId" that can be used to read and write to the file.

Parameters:
name - The name of the file to open.
Returns:
An OpenFileId that uniquely identifies the opened file.

write

public static void write(byte[] buffer,
                         int size,
                         int id)
Write "size" bytes from "buffer" to the open file.

Parameters:
buffer - Location of the data to be written.
size - The number of bytes to write.
id - The OpenFileId of the file to which to write the data.

read

public static int read(byte[] buffer,
                       int size,
                       int id)
Read "size" bytes from the open file into "buffer". Return the number of bytes actually read -- if the open file isn't long enough, or if it is an I/O device, and there aren't enough characters to read, return whatever is available (for I/O devices, you should always wait until you can return at least one character).

Parameters:
buffer - Where to put the data read.
size - The number of bytes requested.
id - The OpenFileId of the file from which to read the data.
Returns:
The actual number of bytes read.

close

public static void close(int id)
Close the file, we're done reading and writing to it.

Parameters:
id - The OpenFileId of the file to be closed.

fork

public static void fork(int func)
Fork a thread to run a procedure ("func") in the *same* address space as the current thread.

Parameters:
func - The user address of the procedure to be run by the new thread.

yield

public static void yield()
Yield the CPU to another runnable thread, whether in this address space or not.