Class Library

Object
  extended byLibrary

public class Library
extends 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 String[] errorMessage
          A table of error messages corresponding to Kernel error return codes.
 
Constructor Summary
private Library()
          This private constructor ensures that no instances of Library are ever created.
 
Method Summary
static int exec(String command, String[] args)
          Performs SYSCALL_EXEC.
static int input(StringBuffer result)
          Performs SYSCALL_INPUT.
static int join(int pid)
          Performs SYSCALL_JOIN.
static int output(String s)
          Performs SYSCALL_OUTPUT.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

errorMessage

public static final 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.

Constructor Detail

Library

private Library()
This private constructor ensures that no instances of Library are ever created.

Method Detail

output

public static int output(String s)
Performs SYSCALL_OUTPUT. Displays text on the console.

Parameters:
s - a String to display
Returns:
zero

input

public static int input(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(String command,
                       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