Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git://scm.gforge.inria.fr/simgrid/simgrid-java
authorSamuel Lepetit <samuel.lepetit@inria.fr>
Fri, 27 Apr 2012 09:08:36 +0000 (11:08 +0200)
committerSamuel Lepetit <samuel.lepetit@inria.fr>
Fri, 27 Apr 2012 09:08:36 +0000 (11:08 +0200)
1  2 
org/simgrid/msg/Process.java

@@@ -76,18 -76,6 +76,18 @@@ public abstract class Process extends T
         * The name of the process.                                                     
         */
        protected String name;
 +      /**
 +        * The PID of the process
 +        */
 +      protected int pid = -1;
 +      /**
 +       * The PPID of the process 
 +       */
 +      protected int ppid = -1;
 +      /**
 +       * The host of the process
 +       */
 +      protected Host host = null;
      /**
       *
       * @return
                        this.args.addAll(Arrays.asList(args));
  
                MsgNative.processCreate(this, host);
 +              
        }
  
  
         * @param process  the process to be killed.
         *
         */
-       public static void kill(Process process) {
-                process.nativeStop();
-                Msg.info("Process " + process.msgName() + " will be killed.");                         
+       public void kill() {
+                nativeStop();
+                Msg.info("Process " + msgName() + " will be killed.");                         
                                 
        }
-       /**
-        * This method adds an argument in the list of the arguments of the main function
-        * of the process. 
-        *
-        * @param arg                   The argument to add.
-      *
-      * @deprecated
-      */
-       @Deprecated
-       protected void addArg(String arg) {
-               args.add(arg);
-       }
  
        /**
         * Suspends the process by suspending the task on which it was
         */ 
        public Host getHost() {
                Process.ifInterruptedStop();
 -              return MsgNative.processGetHost(this);
 +              if (this.host == null) {
 +                      this.host = MsgNative.processGetHost(this);
 +              }
 +              return this.host;
        }
        /**
         * This static method gets a process from a PID.
         */ 
        public int getPID()  {
                Process.ifInterruptedStop();
 -              return MsgNative.processGetPID(this);
 +              if (pid == -1) {
 +                      pid = MsgNative.processGetPID(this);
 +              }
 +              return pid;
        }
        /**
         * This method returns the PID of the parent of a process.
         */ 
        public int getPPID()  {
                Process.ifInterruptedStop();
 -              return MsgNative.processGetPPID(this);
 +              if (ppid == -1) {
 +                      ppid = MsgNative.processGetPPID(this);
 +              }
 +              return ppid;
        }
        /**
         * This static method returns the currently running process.
        public static void migrate(Process process, Host host)  {
                Process.ifInterruptedStop();
                MsgNative.processMigrate(process, host);
 +              process.host = null;
        }
        /**
         * Makes the current process sleep until time seconds have elapsed.