Class Library

java.lang.Object
  |
  +--Library

public class Library
extends java.lang.Object

Convenience calls for using the Kernel. Each function in this class makes a system call. Sometimes, the arguments are manipulated to make their user representation more convenient. Note that this class contains only static methods. All methods return integers. Negative return values are error codes. Some methods return positive values; others simply return 0 to mean "ok".

See Also:
Kernel

Field Summary
static java.lang.String[] errorMessage
          A table of error messages corresponding to Kernel error return codes.
 
Method Summary
static int exec(java.lang.String command, java.lang.String[] args)
          Performs SYSCALL_EXEC.
static long getTime()
           
static int input(java.lang.StringBuffer result)
          Performs SYSCALL_INPUT.
static int join(int pid)
          Performs SYSCALL_JOIN Waits for a process to terminate
static int output(java.lang.String s)
          Performs SYSCALL_OUTPUT.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

errorMessage

public static final java.lang.String[] errorMessage
A table of error messages corresponding to Kernel error return codes. This table should be indexed by the negative of rc, where
          rc = Kernel.interrupt(Kernel.INTERRUPT_USER, ... )
 
and rc is less than 0.
Method Detail

output

public static int output(java.lang.String s)
Performs SYSCALL_OUTPUT. Displays text on the console.
Parameters:
s - a String to display
Returns:
zero

input

public static int input(java.lang.StringBuffer result)
Performs SYSCALL_INPUT. Waits for the user to type some text and hit [return]. The input line is returned in the supplied StringBuffer
Parameters:
result - a place to put the result
Returns:
zero on success, or one of the error codes Kernel.END_OF_FILE or Kernel.ERROR_IO.

exec

public static int exec(java.lang.String command,
                       java.lang.String[] args)
Performs SYSCALL_EXEC. Launchs the named program, and lets it run in parallel to the current program.
Parameters:
command - The name of a Java class to execute.
args - The arguments to give the new program
Returns:
a non-negative process id, or ERROR_BAD_COMMAND.

join

public static int join(int pid)
Performs SYSCALL_JOIN Waits for a process to terminate
Parameters:
pid - a process id returned by a previous call to exec.
Returns:
Zero or ERROR_NO_SUCH_PROCESS

getTime

public static long getTime()