moss.kernel
Class MProcess

java.lang.Object
  extended by java.lang.Thread
      extended by moss.kernel.MProcess
All Implemented Interfaces:
java.lang.Runnable

public class MProcess
extends java.lang.Thread

The MProcess class is effectively the process control block, it extends Thread so it can exist on its own.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 java.lang.String[] cmdline
          command-line arguments
 MEnv environ
          process environment
 MFile[] files
          array of open files (indexed by descriptor)
static int INHERIT_OPEN_FILES
           
 MKernelProcess kernel_if
          handle on a system-process
 boolean ktask
          if true, a kernel-only process
 MProcess next
          previous and next processes on the run-queue
 MProcess next_task
          prev_task and next_task are a linked list of all processes
 MProcess parent
          link to parent process
 MSignal pending_signals
          queue of pending signals
 moss.kernel.MProcess.PFS_mprocess pfslink
          link to the proc-filesystem info handler
 int pid
          process id
 int ppid
          parent process id -- this is not used for active processes
 MProcess prev
          previous and next processes on the run-queue
 MProcess prev_task
          prev_task and next_task are a linked list of all processes
 MProcess q_next
          next process on a wait queue
 int[] sig_handling
          signal-handling states
 boolean signalled
          true if the process has been signalled (allows drivers/etc.
 Semaphore start_sem
          a semaphore used to synchronize process startup
 int state
          state holds the process's state (STOPPED, RUNNING, etc.)
 java.lang.String syscall
          string indicating what system-call the process is doing
static int TASK_FINISHED
           
static int TASK_INVALID
           
static int TASK_RUNNABLE
           
static int TASK_RUNNING
           
static int TASK_SLEEPING
           
static int TASK_STOPPED
           
static int TASK_ZOMBIE
           
 int umask
          the process's file creation mask
 MUserProcess user_if
          handle on a user-process
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
MProcess()
          MProcess constructor.
MProcess(MProcess parent)
          MProcess constructor
 
Method Summary
static int create_kernel_process(java.lang.String name, java.lang.String[] args)
          creates a new kernel process and adds it to the run-queue
static int create_user_process(java.lang.String name, MProcess parent, java.lang.String[] args, int flags)
          creates a new user process and adds it to the run-queue
 void run()
          thread "run" method for an MProcess
static void shutdown_process(MProcess p)
          this is used to tidy-up a process that's shutting down.
static boolean sync_process_signals(MProcess p)
          this method is used by MPosixIf to deliver signals to a process.
 void terminate_process(int exitcode)
          this is called by MPosixIf's exit() to force a process to terminate
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

prev

public MProcess prev
previous and next processes on the run-queue


next

public MProcess next
previous and next processes on the run-queue


q_next

public MProcess q_next
next process on a wait queue


prev_task

public MProcess prev_task
prev_task and next_task are a linked list of all processes


next_task

public MProcess next_task
prev_task and next_task are a linked list of all processes


state

public int state
state holds the process's state (STOPPED, RUNNING, etc.)


sig_handling

public int[] sig_handling
signal-handling states


pending_signals

public MSignal pending_signals
queue of pending signals


signalled

public boolean signalled
true if the process has been signalled (allows drivers/etc. to return EINTR)


pid

public int pid
process id


ppid

public int ppid
parent process id -- this is not used for active processes


parent

public MProcess parent
link to parent process


ktask

public boolean ktask
if true, a kernel-only process


files

public MFile[] files
array of open files (indexed by descriptor)


user_if

public MUserProcess user_if
handle on a user-process


kernel_if

public MKernelProcess kernel_if
handle on a system-process


cmdline

public java.lang.String[] cmdline
command-line arguments


start_sem

public Semaphore start_sem
a semaphore used to synchronize process startup


syscall

public java.lang.String syscall
string indicating what system-call the process is doing


umask

public int umask
the process's file creation mask


environ

public MEnv environ
process environment


pfslink

public moss.kernel.MProcess.PFS_mprocess pfslink
link to the proc-filesystem info handler


TASK_INVALID

public static final int TASK_INVALID
See Also:
Constant Field Values

TASK_STOPPED

public static final int TASK_STOPPED
See Also:
Constant Field Values

TASK_RUNNABLE

public static final int TASK_RUNNABLE
See Also:
Constant Field Values

TASK_RUNNING

public static final int TASK_RUNNING
See Also:
Constant Field Values

TASK_SLEEPING

public static final int TASK_SLEEPING
See Also:
Constant Field Values

TASK_FINISHED

public static final int TASK_FINISHED
See Also:
Constant Field Values

TASK_ZOMBIE

public static final int TASK_ZOMBIE
See Also:
Constant Field Values

INHERIT_OPEN_FILES

public static final int INHERIT_OPEN_FILES
See Also:
Constant Field Values
Constructor Detail

MProcess

public MProcess()
MProcess constructor. Should not be used for constructing things which will become processes; use the other constructor for that.


MProcess

public MProcess(MProcess parent)
MProcess constructor

Parameters:
parent - parent process
Method Detail

create_user_process

public static int create_user_process(java.lang.String name,
                                      MProcess parent,
                                      java.lang.String[] args,
                                      int flags)
creates a new user process and adds it to the run-queue

Parameters:
name - name of the class that provides the process
parent - parent process
args - arguments to be passed to the new process
flags - process creation flags (INHERIT_...)
Returns:
pid of new process on success, -1 on failure

create_kernel_process

public static int create_kernel_process(java.lang.String name,
                                        java.lang.String[] args)
creates a new kernel process and adds it to the run-queue

Parameters:
name - name of the class that provides the process
args - arguments to be passed to the new process
Returns:
pid of new process on success, -1 on failure

shutdown_process

public static void shutdown_process(MProcess p)
this is used to tidy-up a process that's shutting down.

Parameters:
p - process shutting down

terminate_process

public void terminate_process(int exitcode)
this is called by MPosixIf's exit() to force a process to terminate

Parameters:
exitcode - exit-code of the process

run

public void run()
thread "run" method for an MProcess

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

sync_process_signals

public static boolean sync_process_signals(MProcess p)
this method is used by MPosixIf to deliver signals to a process. The body is synchronized (on the process) to prevent races with other processes (on different virtual CPUs) delivering signals

Parameters:
p - process to handle signals for
Returns:
true if signals were processed, false otherwise