Class Kernel
java.lang.Object
|
+----Kernel
- public class Kernel
- extends Object
A simple kernel simulation.
There is only one public interface to this class: interrupt().
System calls, disk notification, and power on messages all arrive
by way of this function.
- Author:
- Douglas Thain (thain@cs.wisc.edu)
- See Also:
- Disk, Library
-
ERROR_BAD_ARGUMENT_TYPE
- One of the system call parameters made no sense
-
ERROR_BAD_COMMAND
- A command passed to SYSCALL_EXEC could not be executed
-
ERROR_END_OF_FILE
- End of file was reached.
-
ERROR_IN_CHILD
- A child program caused an exception and crashed.
-
ERROR_IO
- Miscellaneous error while performing I/O.
-
ERROR_OUT_OF_RANGE
- One parameter was too big or too small
-
INTERRUPT_DISK
- Indicates that a disk caused the interrupt.
-
INTERRUPT_POWER_ON
- Indicates that it's time to start the system.
-
INTERRUPT_USER
- Indicates that a user caused the interrupt.
-
SYSCALL_EXEC
- System call to execute a new program.
-
SYSCALL_EXEC_AND_WAIT
- System call to execute a new program.
-
SYSCALL_INPUT
- System call to read text from the console.
-
SYSCALL_OUTPUT
- System call to output text on the console.
-
Kernel()
-
-
interrupt(int, int, int, Object, Object, byte[])
- This is the only entry into the kernel.
INTERRUPT_USER
public static final int INTERRUPT_USER
- Indicates that a user caused the interrupt.
Parameter i1 -- a valid system call number.
Other parameters depend on the call number.
INTERRUPT_DISK
public static final int INTERRUPT_DISK
- Indicates that a disk caused the interrupt.
All other parameters will be null or zero.
INTERRUPT_POWER_ON
public static final int INTERRUPT_POWER_ON
- Indicates that it's time to start the system.
The Kernel should set up any internal state and
begin executing the first program.
Parameter i1 -- the number of blocks to use in the
disk cache.
Parameter o1 -- the Disk to be used.
SYSCALL_OUTPUT
public static final int SYSCALL_OUTPUT
- System call to output text on the console.
Parameter o1 -- A string to display
Returns -- Zero.
SYSCALL_INPUT
public static final int SYSCALL_INPUT
- System call to read text from the console.
This function returns when the user presses [return].
Parameter o1 -- A StringBuffer to fill with input text.
Returns -- Zero, ERROR_BAD_ARGUMENT_TYPE, ERROR_END_OF_FILE,
or ERROR_IO.
SYSCALL_EXEC
public static final int SYSCALL_EXEC
- System call to execute a new program.
The new program will run in parallel to the current program.
Parameter o1 - The name of a Java class to execute.
Parameter o2 - An array for String arguments.
Returns Zero, ERROR_BAD_ARGUMENT_TYPE,
or ERROR_BAD_COMMAND.
SYSCALL_EXEC_AND_WAIT
public static final int SYSCALL_EXEC_AND_WAIT
- System call to execute a new program.
This call will not return until the newly created program has
run to completion.
Parameter o1 -- The name of a Java class to execute.
Parameter o2 -- An array for String arguments.
Returns -- Zero, ERROR_BAD_ARGUMENT TYPE,
ERROR_BAD_COMMAND, or ERROR_IN_CHILD.
ERROR_BAD_ARGUMENT_TYPE
public static final int ERROR_BAD_ARGUMENT_TYPE
- One of the system call parameters made no sense
ERROR_BAD_COMMAND
public static final int ERROR_BAD_COMMAND
- A command passed to SYSCALL_EXEC could not be executed
ERROR_OUT_OF_RANGE
public static final int ERROR_OUT_OF_RANGE
- One parameter was too big or too small
ERROR_END_OF_FILE
public static final int ERROR_END_OF_FILE
- End of file was reached.
ERROR_IO
public static final int ERROR_IO
- Miscellaneous error while performing I/O.
ERROR_IN_CHILD
public static final int ERROR_IN_CHILD
- A child program caused an exception and crashed.
Kernel
public Kernel()
interrupt
public static int interrupt(int kind,
int i1,
int i2,
Object o1,
Object o2,
byte a[])
- This is the only entry into the kernel.
A user may call this function to perform a system call.
In that case, set kind to INTERRUPT_USER
and set i1 to the system call number. Other
parameters should be set as the system call requires.
A disk may call this function to indicate the current operation
has completed. In that case, kind will be
INTERRUPT_DISK and all parameters will be zero or null.
Important: If the Disk calls interrupt(), the
Kernel should take care of business and return from the interrupt
as soon as possible. All Disk I/O is halted while the interrupt is
being processed.
The boot code may call this function to indicate that the computer
has been turned on and it is time to start the first program
and use the disk. In that case, kind will be
INTERRUPT_POWER_ON, o1 will point to the Disk to be
used, i1 will indicate the size of the buffer cache,
and all other parameters will be zero or null.
- Returns:
- A negative number indicating an error code, or other
values depending on the system call.