2 * JNI interface to virtual machine in Simgrid
4 * Copyright 2006-2012 The SimGrid Team.
7 * This program is free software; you can redistribute
8 * it and/or modify it under the terms of the license
9 * (GNU LGPL) which comes with this package.
11 package org.simgrid.msg;
13 import org.simgrid.msg.Host;
14 import org.simgrid.msg.Process;
16 public class VM extends Host{
17 // Please note that we are not declaring a new bind variable
18 //(the bind variable has been inherited from the super class Host)
20 /* Static functions */
21 // GetByName is inherited from the super class Host
24 /* Constructors / destructors */
26 * Create a `basic' VM (i.e. 1 core, 1GB of RAM, other values are not taken into account).
28 public VM(Host host, String name) {
29 this(host,name,1,1024*1024*1024, -1, null, -1);
33 * Create a `basic' VM (i.e. 1 core, 1GB of RAM, other values are not taken into account).
35 public VM(Host host, String name, int nCore, long ramSize,
36 long netCap, String diskPath, long diskSize){
39 create(host, name, nCore, ramSize, netCap, diskPath, diskSize);
42 protected void finalize() {
47 /* JNI / Native code */
48 /* get/set property methods are inherited from the Host class. */
50 /** Returns whether the given VM is currently suspended
52 public native int isCreated();
54 /** Returns whether the given VM is currently running
56 public native int isRunning();
58 /** Returns whether the given VM is currently running
60 public native int isMigrating();
62 /** Returns whether the given VM is currently suspended
64 public native int isSuspended();
66 /** Returns whether the given VM is currently saving
68 public native int isSaving();
70 /** Returns whether the given VM is currently saved
72 public native int isSaved();
74 /** Returns whether the given VM is currently restoring its state
76 public native boolean isRestoring();
79 * Natively implemented method create the VM.
80 * @param nCore, number of core
81 * @param ramSize, size of the RAM that should be allocated
82 * @param netCap (not used for the moment)
83 * @param diskPath (not used for the moment)
84 * @param diskSize (not used for the moment)
86 private native void create(Host host, String name, int nCore, long ramSize,
87 long netCap, String diskPath, long diskSize);
92 public native void start();
96 * Immediately kills all processes within the given VM. Any memory that they allocated will be leaked.
97 * No extra delay occurs. If you want to simulate this too, you want to use a MSG_process_sleep() or something
99 public native void shutdown();
102 /** Immediately change the host on which all processes are running
104 * No migration cost occurs. If you want to simulate this too, you want to use a
105 * Task.send() before or after, depending on whether you want to do cold or hot
108 public native void migrate(Host destination);
110 /** Immediately suspend the execution of all processes within the given VM
112 * No suspension cost occurs. If you want to simulate this too, you want to
113 * use a \ref File.write() before or after, depending on the exact semantic
114 * of VM suspend to you.
116 public native void suspend();
118 /** Immediately resumes the execution of all processes within the given VM
120 * No resume cost occurs. If you want to simulate this too, you want to
121 * use a \ref File.read() before or after, depending on the exact semantic
122 * of VM resume to you.
124 public native void resume();
126 /** Immediately suspend the execution of all processes within the given VM
127 * and save its state on the persistent HDD
128 * Not yet implemented (for the moment it behaves like suspend)
129 * No suspension cost occurs. If you want to simulate this too, you want to
130 * use a \ref File.write() before or after, depending on the exact semantic
131 * of VM suspend to you.
133 public native void save();
135 /** Immediately resumes the execution of all processes previously saved
136 * within the given VM
137 * Not yet implemented (for the moment it behaves like resume)
139 * No resume cost occurs. If you want to simulate this too, you want to
140 * use a \ref File.read() before or after, depending on the exact semantic
141 * of VM resume to you.
143 public native void restore();
149 protected native void destroy();
154 * Class initializer, to initialize various JNI stuff
156 public static native void nativeInit();