moss.kernel
Class MKernel

java.lang.Object
  extended by moss.kernel.MKernel

public class MKernel
extends java.lang.Object


Field Summary
static MProcess[] current
          array of active processes by CPU.
static MProcess init_task
          the special "init task"
static MProcessor[] processors
          virtual processor objects
static MProcess task_list
          task list
 
Constructor Summary
MKernel()
           
 
Method Summary
static void add_to_run_queue(MProcess p)
          adds a process to the run-queue.
static void add_to_task_list(MProcess p)
          adds a process to the global task list.
static void deliver_process_signals(MProcess p)
          this delivers any pending signals to process p.
static void ending_process(MProcess p, int exitcode)
          this is invoked by a process as it finishes.
static void finalinit()
          this is called by the init-task as the first thing it does; final kernel setup happens here, and we're in the context of the init-process.
static MProcess find_process(int pid)
          finds a process from its PID
static void first_process(MProcess p)
          this is called once to set the first process up.
static int get_free_pid()
          returns a free PID (and stops it being allocated again until released)
static MProcess[] get_process_list()
          extracts a process list.
static void init_kernel(MProcessor[] cpus, java.io.PrintStream msgs)
          initialises the kernel
static void log_msg(java.lang.String msg)
          generates a kernel `log' message
static void module_fault(MProcess p, java.lang.RuntimeException e)
          called when a kernel module generates a run-time error
static void panic(java.lang.String message)
          causes a kernel panic; that aborts the simulator
static void process_fault(MProcess p, java.lang.RuntimeException e)
          called when a process generates a run-time error (typically caught RuntimeExceptions for main-code or signal-handling).
static void queue_signal(MProcess p, MSignal signal)
          queues a signal to be delivered to the given process
static void quiet_add_to_run_queue(MProcess p)
          adds a process to the run-queue.
static void release_free_pid(int pid)
          returns a used PID to the system
static void remove_from_task_list(MProcess p)
          removes a process from the global task queue.
static void schedule()
          this deschedules the current process, picks a new process from the run-queue and runs it.
static void start_process(MProcess p)
          this is called to start a new process.
static void starting_process(MProcess p)
          this is invoked by a process as it starts up -- not "running" as far as MOSS is concerned.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

current

public static MProcess[] current
array of active processes by CPU.


init_task

public static MProcess init_task
the special "init task"


task_list

public static MProcess task_list
task list


processors

public static MProcessor[] processors
virtual processor objects

Constructor Detail

MKernel

public MKernel()
Method Detail

init_kernel

public static void init_kernel(MProcessor[] cpus,
                               java.io.PrintStream msgs)
initialises the kernel

Parameters:
cpus - array of virtual processors to use
msgs - somewhere we can write boot-messages

panic

public static void panic(java.lang.String message)
causes a kernel panic; that aborts the simulator

Parameters:
message - informational message

log_msg

public static void log_msg(java.lang.String msg)
generates a kernel `log' message

Parameters:
msg - log string (without terminating newline)

schedule

public static void schedule()
this deschedules the current process, picks a new process from the run-queue and runs it.


first_process

public static void first_process(MProcess p)
this is called once to set the first process up. It gets PID 1.

Parameters:
p - an INVALID MProcess (not started as a Thread, yet)

finalinit

public static void finalinit()
this is called by the init-task as the first thing it does; final kernel setup happens here, and we're in the context of the init-process.


starting_process

public static void starting_process(MProcess p)
this is invoked by a process as it starts up -- not "running" as far as MOSS is concerned. When this returns, it is as a properly running MOSS process. The other half of this is performed by start_process

Parameters:
p - process that is starting

ending_process

public static void ending_process(MProcess p,
                                  int exitcode)
this is invoked by a process as it finishes.


start_process

public static void start_process(MProcess p)
this is called to start a new process. The process given should be a non-started MProcess (extending Java's Thread).

Parameters:
p - process to be started

get_free_pid

public static int get_free_pid()
returns a free PID (and stops it being allocated again until released)


release_free_pid

public static void release_free_pid(int pid)
returns a used PID to the system

Parameters:
pid - process-ID no longer in use

quiet_add_to_run_queue

public static void quiet_add_to_run_queue(MProcess p)
adds a process to the run-queue. Does not attempt to schedule process.


add_to_run_queue

public static void add_to_run_queue(MProcess p)
adds a process to the run-queue. If its not already running, and there is a free-processor, it is dispatched immediately.

Parameters:
p - process to add. Must not be on any other queue!

add_to_task_list

public static void add_to_task_list(MProcess p)
adds a process to the global task list. Should only be used when creating a new process.

Parameters:
p - process to add

remove_from_task_list

public static void remove_from_task_list(MProcess p)
removes a process from the global task queue. Should only be used when destroying a process.

Parameters:
p - process to remove

find_process

public static MProcess find_process(int pid)
finds a process from its PID

Parameters:
pid - PID of process to search for
Returns:
MProcess reference on success, or null if not found

deliver_process_signals

public static void deliver_process_signals(MProcess p)
this delivers any pending signals to process p. This (p) *must* be the/a current process..

Parameters:
p - a current process

queue_signal

public static void queue_signal(MProcess p,
                                MSignal signal)
queues a signal to be delivered to the given process

Parameters:
p - process to be signalled
signal - signal to be delivered

get_process_list

public static MProcess[] get_process_list()
extracts a process list. This returns an array of MProcess's, that are semi-populated copies of the real ones. There must be at least one..!

Returns:
array of process "control blocks"

process_fault

public static void process_fault(MProcess p,
                                 java.lang.RuntimeException e)
called when a process generates a run-time error (typically caught RuntimeExceptions for main-code or signal-handling).

Parameters:
p - process that faulted
e - Java RuntimeException generated

module_fault

public static void module_fault(MProcess p,
                                java.lang.RuntimeException e)
called when a kernel module generates a run-time error

Parameters:
p - process that faulted
e - Java RuntimeException generated