2 * simgrid.msg.Task.java 1.00 07/05/01
4 * Copyright 2006,2007 Martin Quinson, Malek Cherier
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.
15 * Since most scheduling algorithms rely on a concept of
16 * task that can be either computed locally or transferred
17 * on another processor, it seems to be the right level of
18 * abstraction for our purposes. A task may then be defined
19 * by a computing amount, a message size and some private
20 * data. To transfer a task you use an instance of the class
21 * Channel identified by an number.
23 * @author Abdelmalek Cherier
24 * @author Martin Quinson
25 * @version 1.00, 07/05/01
33 * This attribute represents a bind between a java task object and
34 * a native task. Even if this attribute is public you must never
35 * access to it. It is set automaticatly during the build of the object.
40 * Default constructor (disabled)
45 * Construct an new task with the specified processing amount and amount
48 * @param name The name of th task.
50 * @param computeDuration A value of the processing amount (in flop) needed
51 * to process the task. If 0, then it cannot be executed
52 * with the execute() method. This value has to be >= 0.
54 * @param messageSize A value of amount of data (in bytes) needed to transfert
55 * this task. If 0, then it cannot be transfered this task.
56 * If 0, then it cannot be transfered with the get() and put()
57 * methods. This value has to be >= 0.
59 * @exception InvalidTaskNameException if the specified name is null.
60 * InvalidComputeDuration if the specified compute duration is less than 0.
61 * InvalidMessageSizeException if the specified message size is less than 0.
63 public Task(String name, double computeDuration,
64 double messageSize) throws JniException {
66 create(name, computeDuration, messageSize);
69 * This method creates a new task with the specified features. The task
70 * creation means that the native task is created and binded with the
71 * java task instance. If the task is already created you must destroy it
72 * before to use this method, otherwise the method throws the exception
73 * TaskAlreadyCreatedException.
75 * @param name The name of the task.
76 * @param computeDuration A value of the processing amount (in flop) needed
77 * to process the task. If 0, then it cannot be executed
78 * with the execute() method. This value has to be >= 0.
79 * @param messageSize A value of amount of data (in bytes) needed to transfert
80 * this task. If 0, then it cannot be transfered this task.
81 * If 0, then it cannot be transfered with the get() and put()
82 * methods. This value has to be >= 0.
84 * @exception InvalidTaskNameException if the specified name is null.
85 * InvalidComputeDuration if the specified compute duration is less than 0.
86 * InvalidMessageSizeException if the specified message size is less than 0.
88 public void create(String name, double computeDuration,
89 double messageSize) throws JniException {
92 Msg.taskCreate(this, name, computeDuration, messageSize);
95 * This method gets the sender of the task.
97 * @return The sender of the task.
99 * @exception InvalidTaskException is the specified task is not valid. A task
100 * is invalid if it is not binded with a native task.
102 */ Process getSender() throws JniException {
103 return Msg.taskGetSender(this);
106 * This method gets the source of the task.
108 * @return The source of the task.
110 * @exception InvalidTaskException is the specified task is not valid. A task
111 * is invalid if it is not binded with a native task.
112 */ public Host getSource() throws JniException, NativeException {
113 return Msg.taskGetSource(this);
116 * This method gets the name of a task.
118 * @return The name of the task.
120 * @exception InvalidTaskException is the specified task is not valid. A task
121 * is invalid if it is not binded with a native task.
122 */ public String getName() throws JniException {
123 return Msg.taskGetName(this);
126 * This method cancels a task.
128 * @exception InvalidTaskException if the specified task is not valid. A task
129 * is invalid if it is not binded with a native task.
130 * MsgException if the cancelation failed.
131 */ public void cancel() throws JniException, NativeException {
132 Msg.taskCancel(this);
135 * This method gets the computing amount of the task.
137 * @return The computing amount of the task.
139 * @exception InvalidTaskException is the specified task is not valid. A task
140 * is invalid if it is not binded with a native task.
141 */ public double getComputeDuration() throws JniException {
142 return Msg.taskGetComputeDuration(this);
145 * This method gets the remaining computation.
147 * @return The remaining duration.
149 * @exception InvalidTaskException is the specified task is not valid. A task
150 * is invalid if it is not binded with a native task.
151 */ public double getRemainingDuration() throws JniException {
152 return Msg.taskGetRemainingDuration(this);
155 * This method sets the priority of the computation of the task.
156 * The priority doesn't affect the transfert rate. For example a
157 * priority of 2 will make the task receive two times more cpu than
160 * @param The new priority of the task.
162 * @exception InvalidTaskException is the specified task is not valid. A task
163 * is invalid if it is not binded with a native task.
164 */ public void setPrirority(double priority) throws JniException {
165 Msg.taskSetPriority(this, priority);
168 * This method destroys a task.
170 * @exception InvalidTaskException is the specified task is not valid. A task
171 * is invalid if it is not binded with a native task.
172 * MsgException if the destruction failed.
173 */ public void destroy() throws JniException, NativeException {
174 if (this.bind != 0) {
175 Msg.taskDestroy(this);
180 * This method deletes a task.
182 * @exception InvalidTaskException is the specified task is not valid. A task
183 * is invalid if it is not binded with a native task.
184 * MsgException if the destruction failed.
185 */ protected void finalize() throws JniException, NativeException {
187 Msg.taskDestroy(this);
190 * This method execute a task on the location on which the
191 * process is running.
193 * @exception InvalidTaskException is the specified task is not valid. A task
194 * is invalid if it is not binded with a native task.
195 * MsgException if the destruction failed.
196 */ public void execute() throws JniException, NativeException {
197 Msg.taskExecute(this);