public abstract class Process
extends java.lang.Object
implements java.lang.Runnable
Modifier and Type | Field and Description |
---|---|
protected double |
startTime
Time at which the process should be created
|
Constructor and Description |
---|
Process(Host host,
java.lang.String name)
Constructs a new process from a host and his name.
|
Process(Host host,
java.lang.String name,
java.lang.String[] args)
Constructs a new process from a host and his name, the arguments of here method function are
specified by the parameter args.
|
Process(Host host,
java.lang.String name,
java.lang.String[] args,
double startTime,
double killTime)
Constructs a new process from a host and his name, the arguments of here method function are
specified by the parameter args.
|
Process(java.lang.String hostname,
java.lang.String name)
Constructs a new process from the name of a host and his name.
|
Process(java.lang.String hostname,
java.lang.String name,
java.lang.String[] args)
Constructs a new process from the name of a host and his name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
create(Host host)
The native method to create an MSG process.
|
void |
exit()
Stops the execution of the current actor
|
static Process |
fromPID(int pid)
This static method gets a process from a PID.
|
static int |
getCount()
This static method returns the current amount of processes running
|
static Process |
getCurrentProcess()
This static method returns the currently running process.
|
Host |
getHost()
Returns the host of the process.
|
java.lang.String |
getName()
Returns the name of the process
|
int |
getPID()
This method returns the PID of the process.
|
int |
getPPID()
This method returns the PID of the parent of a process.
|
java.lang.String |
getProperty(java.lang.String name)
Returns the value of a given process property.
|
boolean |
isSuspended()
Tests if a process is suspended.
|
void |
kill()
Simply kills the receiving process.
|
static void |
kill(Process p) |
static int |
killAll(int resetPID)
This method kills all running process of the simulation.
|
abstract void |
main(java.lang.String[] args)
The main function of the process (to implement).
|
void |
migrate(Host host)
Migrates a process to another host.
|
void |
restart()
Restarts the process from the beginning
|
void |
resume()
Resume a process that was suspended by
suspend() . |
void |
run()
This method runs the process.
|
void |
setAutoRestart(boolean autoRestart)
Specify whether the process should restart when its host restarts after a failure
A process naturally stops when its host stops.
|
void |
setKillTime(double killTime)
Set the kill time of the process
|
static void |
sleep(long millis)
Makes the current process sleep until millis milliseconds have elapsed.
|
static void |
sleep(long millis,
int nanos)
Makes the current process sleep until millis milliseconds and nanos nanoseconds
have elapsed.
|
void |
start()
This method actually creates and run the process.
|
void |
suspend()
Suspends the process.
|
void |
waitFor(double seconds)
Makes the current process sleep until time seconds have elapsed.
|
static void |
yield()
Yield the current process.
|
public Process(java.lang.String hostname, java.lang.String name) throws HostNotFoundException
hostname
- Where to create the process.name
- The name of the process.HostNotFoundException
- if no host with this name exists.public Process(java.lang.String hostname, java.lang.String name, java.lang.String[] args) throws HostNotFoundException
hostname
- Where to create the process.name
- The name of the process.args
- The arguments of the main function of the process.HostNotFoundException
- if no host with this name exists.public Process(Host host, java.lang.String name)
host
- Where to create the process.name
- The name of the process.public Process(Host host, java.lang.String name, java.lang.String[] args)
host
- Where to create the process.name
- The name of the process.args
- The arguments of main method of the process.public Process(Host host, java.lang.String name, java.lang.String[] args, double startTime, double killTime)
host
- Where to create the process.name
- The name of the process.args
- The arguments of main method of the process.startTime
- Start time of the processkillTime
- Kill time of the processprotected void create(Host host)
host
- where to create the process.public static int killAll(int resetPID)
resetPID
- Should we reset the PID numbers. A negative number means no reset
and a positive number will be used to set the PID of the next newly
created process.public void kill()
public static void kill(Process p)
public void suspend()
resume()
to resume it afterwardpublic void resume()
suspend()
.public boolean isSuspended()
public static void yield()
public void setAutoRestart(boolean autoRestart)
public void restart()
public java.lang.String getName()
public Host getHost()
public static Process fromPID(int pid)
pid
- The process identifier of the process to get.public int getPID()
public int getPPID()
public java.lang.String getProperty(java.lang.String name)
public void setKillTime(double killTime)
killTime
- the time when the process is killedpublic static Process getCurrentProcess()
public void migrate(Host host)
host
- The host where to migrate the process.public static void sleep(long millis) throws HostFailureException
millis
- the length of time to sleep in milliseconds.HostFailureException
public static void sleep(long millis, int nanos) throws HostFailureException
waitFor(double)
which takes seconds, this method takes
milliseconds and nanoseconds.
Overloads Thread.sleep.millis
- the length of time to sleep in milliseconds.nanos
- additional nanoseconds to sleep.HostFailureException
public void waitFor(double seconds) throws HostFailureException
seconds
- The time the current process must sleep.HostFailureException
public final void start() throws HostNotFoundException
HostNotFoundException
public void run()
run
in interface java.lang.Runnable
public abstract void main(java.lang.String[] args) throws MsgException
args
- MsgException
public void exit()
public static int getCount()