class org.simgrid.msg… java:import:: java.util Arrays

Process

public abstract class Process implements Runnable

A process may be defined as a code, with some private data, executing in a location (host). All the process used by your simulation must be declared in the deployment file (XML format). To create your own process you must inherit your own process from this class and override the method “main()”. For example if you want to use a process named Slave proceed as it : (1) import the class Process of the package simgrid.msg import simgrid.msg.Process; public class Slave extends simgrid.msg.Process { (2) Override the method function verbatim public void main(String[] args) { System.out.println(“Hello MSG”); } endverbatim } The name of your process must be declared in the deployment file of your simulation. For the example, for the previous process Slave this file must contains a line : <process host=”Maxims” function=”Slave”/>, where Maxims is the host of the process Slave. All the process of your simulation are automatically launched and managed by Msg. A process use tasks to simulate communications or computations with another process. For more information see Task. For more information on host concept see Host.

Fields

startTime

protected double startTime

Time at which the process should be created

Constructors

Process

public Process(String hostname, String name)

Constructs a new process from the name of a host and his name. The method function of the process doesn’t have argument.

Parameters:
  • hostname – Where to create the process.
  • name – The name of the process.
Throws:
  • HostNotFoundException – if no host with this name exists.

Process

public Process(String hostname, String name, String[] args)

Constructs a new process from the name of a host and his name. The arguments of the method function of the process are specified by the parameter args.

Parameters:
  • hostname – Where to create the process.
  • name – The name of the process.
  • args – The arguments of the main function of the process.
Throws:
  • HostNotFoundException – if no host with this name exists.

Process

public Process(Host host, String name)

Constructs a new process from a host and his name. The method function of the process doesn’t have argument.

Parameters:
  • host – Where to create the process.
  • name – The name of the process.

Process

public Process(Host host, String name, String[] argsParam)

Constructs a new process from a host and his name, the arguments of here method function are specified by the parameter args.

Parameters:
  • host – Where to create the process.
  • name – The name of the process.
  • argsParam – The arguments of main method of the process.

Process

public Process(Host host, String name, 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.

Parameters:
  • 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 process
  • killTime – Kill time of the process

Methods

create

protected native void create(Host host)

The native method to create an MSG process.

Parameters:
  • host – where to create the process.

exit

public void exit()

Stops the execution of the current actor

fromPID

public static native Process fromPID(int pid)

This static method gets a process from a PID.

Parameters:
  • pid – The process identifier of the process to get.
Returns:

The process with the specified PID.

getCount

public static native int getCount()

This static method returns the current amount of processes running

Returns:The count of the running processes

getCurrentProcess

public static native Process getCurrentProcess()

This static method returns the currently running process.

Returns:The current process.

getHost

public Host getHost()

Returns the host of the process.

Returns:The host instance of the process.

getName

public String getName()

Returns the name of the process

getPID

public int getPID()

This method returns the PID of the process.

Returns:The PID of the process.

getPPID

public int getPPID()

This method returns the PID of the parent of a process.

Returns:The PID of the parent of the process.

getProperty

public native String getProperty(String name)

Returns the value of a given process property.

isSuspended

public native boolean isSuspended()

Tests if a process is suspended.

See also: .suspend(), .resume()

kill

public native void kill()

Simply kills the receiving process. SimGrid sometimes have issues when you kill processes that are currently communicating and such. We are working on it to fix the issues.

kill

public static void kill(Process p)

killAll

public static native void killAll()

This method kills all running process of the simulation.

main

public abstract void main(String[] args)

The main function of the process (to implement by the user).

Parameters:
  • args
Throws:

migrate

public native void migrate(Host host)

Migrates a process to another host.

Parameters:
  • host – The host where to migrate the process.

restart

public native void restart()

Restarts the process from the beginning

resume

public native void resume()

Resume a process that was suspended by suspend().

run

public void run()

This method runs the process. It calls the method function that you must overwrite.

setAutoRestart

public native 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. It starts again only if autoRestart is set to true. Otherwise, it just disappears when the host stops.

setKillTime

public native void setKillTime(double killTime)

Set the kill time of the process

Parameters:
  • killTime – the time when the process is killed

sleep

public static void sleep(long millis)

Makes the current process sleep until millis milliseconds have elapsed. You should note that unlike “waitFor” which takes seconds, this method takes milliseconds. FIXME: Not optimal, maybe we should have two native functions.

Parameters:
  • millis – the length of time to sleep in milliseconds.

sleep

public static native void sleep(long millis, int nanos)

Makes the current process sleep until millis milliseconds and nanos nanoseconds have elapsed. Unlike waitFor(double) which takes seconds, this method takes milliseconds and nanoseconds. Overloads Thread.sleep.

Parameters:
  • millis – the length of time to sleep in milliseconds.
  • nanos – additional nanoseconds to sleep.

start

public final void start()

This method actually creates and run the process. It is a noop if the process is already launched.

suspend

public native void suspend()

Suspends the process. See resume() to resume it afterward

waitFor

public native void waitFor(double seconds)

Makes the current process sleep until time seconds have elapsed.

Parameters:
  • seconds – The time the current process must sleep.

yield

public static native void yield()

Yield the current process. All other processes that are ready at the same timestamp will be executed first