psimjava
Class Process

java.lang.Object
  extended by java.lang.Thread
      extended by psimjava.Pobject
          extended by psimjava.Sched
              extended by psimjava.Process
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
Comm_timer

public abstract class Process
extends Sched

Basic behavior of a process in PsimJ.

The user's Java classes for processes must inherit this class.

PsimJ, a java package for OO discrete-event simulation. (C) Jose M. Garrido, June 2000, August 2003, Oct 2004, 2007


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
protected Process(java.lang.String pname)
          Constructor for processes.
 
Method Summary
 void clear_int_lev(int intlev)
          Clears the Psim interrupt level of the process (to zero).
 void clear_int()
          Clears the Psim interrupt levels of the process (to zero).
 boolean comm_wait()
          Gets the value of the communication flag of the calling process.
 void deactivate(Process p)
          Deactivates (i.e.) suspends the called process.
 void delay(double d)
          Schedules the calling process at 'd' time units from the current clock time In the mean time, the process remains active in the event list waiting for the time to become the currently running process.
 java.lang.String get_name()
          Gets the name of the calling process (activate object).
 double get_remain_t()
          Get the remaining interval left after the process has been interrupted.
 boolean idle()
          Checks if the process is idle (i.e., has been suspended).
 int int_level()
          Gets the lowest interrupt level greater than zero of the process.
 int int_level(int intlev)
          Gets the interrupt level specified of the process.
 boolean is_terminated()
          Checks if the calling process has been terminated.
protected abstract  void Main_body()
          This method represents the main code of every user process.
 void p_interrupt(int int_level)
          Interrupts the calling process using the specified interrupt level.
 void reactivate(Process p)
          Reactivates the called process.
 void run()
          This method sets up and starts executing the main body of the process.
 void schedat(double timeat)
          Schedules the called process at time 'timeat'.
 void set_comm_flag(boolean flag)
          Sets the communication flag to the specified truth value
 void start()
          This method overides the start method in the Java Thread class It inserts the Process into the out queue and then starts the thread running It must be called to have the Process actually start running
 void terminate()
          Terminates the called process (object).
 
Methods inherited from class psimjava.Sched
get_clock, rdstate, rdtime, set_state
 
Methods inherited from class psimjava.Pobject
get_prio, set_prio
 
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, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Process

protected Process(java.lang.String pname)
Constructor for processes. It initializes the process to an appropriate state.

Parameters:
pname - String, the name to assigned to the process.
Method Detail

start

public void start()
This method overides the start method in the Java Thread class It inserts the Process into the out queue and then starts the thread running It must be called to have the Process actually start running

Overrides:
start in class java.lang.Thread

get_name

public java.lang.String get_name()
Gets the name of the calling process (activate object).

Returns:
String Returns the String with the name of the process

terminate

public void terminate()
Terminates the called process (object). Change the state of the process to TERMINATED, and the time of the next event to zero.


is_terminated

public boolean is_terminated()
Checks if the calling process has been terminated.

Returns:
boolean Returns 'true' if the process has been terminated, otherwise returns 'false'.

deactivate

public void deactivate(Process p)
Deactivates (i.e.) suspends the called process. The process will remain suspended until another process reactivates it.

Parameters:
p - Process, the process to suspend.

reactivate

public void reactivate(Process p)
Reactivates the called process. The called process becomes activate again to be scheduled and carry out normal activities.

Parameters:
p - Process, the process to reactivate.

delay

public void delay(double d)
Schedules the calling process at 'd' time units from the current clock time In the mean time, the process remains active in the event list waiting for the time to become the currently running process.

Parameters:
d - double, the interval from the current simulation time after which the current process will become the rurring process.

p_interrupt

public void p_interrupt(int int_level)
Interrupts the calling process using the specified interrupt level. The interrupted process is rescheduled immediately so it can take appropriate action. Note that this is different from the Java Thread interrupt.

Parameters:
int_level - int, the interrupt level used with the interrupt.

get_remain_t

public double get_remain_t()
Get the remaining interval left after the process has been interrupted.

Returns:
double the period left of the interrupted process (a value of type double).

schedat

public void schedat(double timeat)
Schedules the called process at time 'timeat'. At that instant, the process will become the running process.

Parameters:
timeat - double, the instant at which the calling process will be scheduled.

run

public void run()
This method sets up and starts executing the main body of the process. This method is called by the 'start' method in the Java Thread package.

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

Main_body

protected abstract void Main_body()
This method represents the main code of every user process. It normally contains the more specialized behavior of the user process. Therefore every user process must implement (override) this method.


clear_int

public void clear_int()
Clears the Psim interrupt levels of the process (to zero). Note that this is different than the Java Thread interrupt mechanism.


clear_int_lev

public void clear_int_lev(int intlev)
Clears the Psim interrupt level of the process (to zero). The argument specifies the interrupt level to clear.


int_level

public int int_level()
Gets the lowest interrupt level greater than zero of the process. This value is zero if the process has not been interrupted, or the interrupt levels have been cleared.

Returns:
int returns an integer value that represents the lowest interrupt level set of the process.

int_level

public int int_level(int intlev)
Gets the interrupt level specified of the process. This value is zero if the process has not been interrupted with this level, or the interrupt level has been cleared.

Returns:
int returns an integer value that represents the interrupt level of the process.

idle

public boolean idle()
Checks if the process is idle (i.e., has been suspended).

Returns:
boolean Returns true if the process is idle, otherwise returns false.

comm_wait

public boolean comm_wait()
Gets the value of the communication flag of the calling process.

Returns:
boolean Returns the value of the communication flag, true if the process is waiting to communicate

set_comm_flag

public void set_comm_flag(boolean flag)
Sets the communication flag to the specified truth value

Parameters:
flag - boolean, the boolean value to set the communication flag