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
34 * This attribute represents a bind between a java task object and
35 * a native task. Even if this attribute is public you must never
36 * access to it. It is set automaticatly during the build of the object.
41 * Default constructor (disabled)
46 * Construct an new task with the specified processing amount and amount
49 * @param name The name of th task.
51 * @param computeDuration A value of the processing amount (in flop) needed
52 * to process the task. If 0, then it cannot be executed
53 * with the execute() method. This value has to be >= 0.
55 * @param messageSize A value of amount of data (in bytes) needed to transfert
56 * this task. If 0, then it cannot be transfered this task.
57 * If 0, then it cannot be transfered with the get() and put()
58 * methods. This value has to be >= 0.
60 * @exception InvalidTaskNameException if the specified name is null.
61 * InvalidComputeDuration if the specified compute duration is less than 0.
62 * InvalidMessageSizeException if the specified message size is less than 0.
64 public Task(String name, double computeDuration, double messageSize) throws JniException {
66 create(name,computeDuration,messageSize);
70 * This method creates a new task with the specified features. The task
71 * creation means that the native task is created and binded with the
72 * java task instance. If the task is already created you must destroy it
73 * before to use this method, otherwise the method throws the exception
74 * TaskAlreadyCreatedException.
76 * @param name The name of the task.
77 * @param computeDuration A value of the processing amount (in flop) needed
78 * to process the task. If 0, then it cannot be executed
79 * with the execute() method. This value has to be >= 0.
80 * @param messageSize A value of amount of data (in bytes) needed to transfert
81 * this task. If 0, then it cannot be transfered this task.
82 * If 0, then it cannot be transfered with the get() and put()
83 * methods. This value has to be >= 0.
85 * @exception InvalidTaskNameException if the specified name is null.
86 * InvalidComputeDuration if the specified compute duration is less than 0.
87 * InvalidMessageSizeException if the specified message size is less than 0.
89 public void create(String name, double computeDuration, double messageSize) throws JniException {
92 Msg.taskCreate(this,name,computeDuration,messageSize);
96 * This method gets the sender of the task.
98 * @return The sender of the task.
100 * @exception InvalidTaskException is the specified task is not valid. A task
101 * is invalid if it is not binded with a native task.
104 Process getSender() throws JniException{
105 return Msg.taskGetSender(this);
109 * This method gets the source of the task.
111 * @return The source of the task.
113 * @exception InvalidTaskException is the specified task is not valid. A task
114 * is invalid if it is not binded with a native task.
116 public Host getSource()throws JniException, NativeException{
117 return Msg.taskGetSource(this);
121 * This method gets the name of a task.
123 * @return The name of the task.
125 * @exception InvalidTaskException is the specified task is not valid. A task
126 * is invalid if it is not binded with a native task.
128 public String getName()throws JniException{
129 return Msg.taskGetName(this);
133 * This method cancels a task.
135 * @exception InvalidTaskException if the specified task is not valid. A task
136 * is invalid if it is not binded with a native task.
137 * MsgException if the cancelation failed.
139 public void cancel() throws JniException, NativeException{
140 Msg.taskCancel(this);
144 * This method gets the computing amount of the task.
146 * @return The computing amount of the task.
148 * @exception InvalidTaskException is the specified task is not valid. A task
149 * is invalid if it is not binded with a native task.
151 public double getComputeDuration()throws JniException{
152 return Msg.taskGetComputeDuration(this);
156 * This method gets the remaining computation.
158 * @return The remaining duration.
160 * @exception InvalidTaskException is the specified task is not valid. A task
161 * is invalid if it is not binded with a native task.
163 public double getRemainingDuration() throws JniException {
164 return Msg.taskGetRemainingDuration(this);
168 * This method sets the priority of the computation of the task.
169 * The priority doesn't affect the transfert rate. For example a
170 * priority of 2 will make the task receive two times more cpu than
173 * @param The new priority of the task.
175 * @exception InvalidTaskException is the specified task is not valid. A task
176 * is invalid if it is not binded with a native task.
178 public void setPrirority(double priority) throws JniException {
179 Msg.taskSetPriority(this,priority);
183 * This method destroys a task.
185 * @exception InvalidTaskException is the specified task is not valid. A task
186 * is invalid if it is not binded with a native task.
187 * MsgException if the destruction failed.
189 public void destroy() throws JniException, NativeException {
191 Msg.taskDestroy(this);
197 * This method deletes a task.
199 * @exception InvalidTaskException is the specified task is not valid. A task
200 * is invalid if it is not binded with a native task.
201 * MsgException if the destruction failed.
203 protected void finalize() throws JniException, NativeException {
205 Msg.taskDestroy(this);
209 * This method execute a task on the location on which the
210 * process is running.
212 * @exception InvalidTaskException is the specified task is not valid. A task
213 * is invalid if it is not binded with a native task.
214 * MsgException if the destruction failed.
216 public void execute() throws JniException, NativeException {
217 Msg.taskExecute(this);