001 // Schedulable.java, created by cata 002 // Copyright (C) 2001 Catalin Francu <cata@mit.edu> 003 // Licensed under the terms of the GNU GPL; see COPYING for details. 004 005 package javax.realtime; 006 import java.io.*; 007 008 /** Handlers and other objects can be run by a <code>Scheduler</code> if they 009 * provide a <code>run()</code> method and the methods defined below. The 010 * <code>Scheduler</code> uses this information to create a suitable context 011 * to execute the <code>run()</code> method. 012 */ 013 public interface Schedulable extends java.lang.Runnable { 014 015 /** Add the scheduling and release characteristics of <code>this</code> 016 * to the set of such chracteristics already being considered, if the 017 * addition would result in the new, larger set being feasible. 018 * 019 * @return True, if the addition would result in the set of considered 020 * characteristics being feasible. False, if the addition would 021 * result in the sed of considered characteristics being infeasible 022 * or there is no assigned instance of <code>Scheduler</code>. 023 */ 024 public boolean addIfFeasible(); 025 026 /** Inform the scheduler and cooperating facilities that scheduling and 027 * release characteristics of this instance of <code>Schedulable</code> 028 * should be considered in feasibility analysis until further notified. 029 * 030 * @return True, if the addition was successful. False, if not. 031 */ 032 public boolean addToFeasibility(); 033 034 /** Gets a reference to the <code>MemoryParameters</code> object. 035 * 036 * @return A reference to the current <code>MemoryParameters</code> object. 037 */ 038 public MemoryParameters getMemoryParameters(); 039 040 /** Gets a reference to the <code>ProcessingGroupParameters</code> object. 041 * 042 * @return A reference to the current <code>ProcessingGroupParameters</code> object. 043 */ 044 public ProcessingGroupParameters getProcessingGroupParameters(); 045 046 /** Gets a reference to the <code>ReleaseParameters</code> object. 047 * 048 * @return A reference to the current <code>ReleaseParameters</code> object. 049 */ 050 public ReleaseParameters getReleaseParameters(); 051 052 /** Gets a reference to the <code>SchedulingParameters</code> object. 053 * 054 * @return A reference to the current <code>SchedulingParameters</code> object. 055 */ 056 public SchedulingParameters getSchedulingParameters(); 057 058 /** Gets a reference to the <code>Scheduler</code> object. 059 * 060 * @return A reference to the current <code>Scheduler</code> object. 061 */ 062 public Scheduler getScheduler(); 063 064 /** Inform the scheduler and cooperating facilities that scheduling and 065 * release characteristics of this instance of <code>Schedulable</code> should 066 * <i>not</i> be considered in feasibility analysis until further notified. 067 * 068 * @return True, if the removal was successful. False, if not. 069 */ 070 public void removeFromFeasibility(); 071 072 /** This method appears in many classes in the RTSJ and with various parameters. 073 * The parameters are either new scheduling characteristics for an instance of 074 * <code>Schedulable</code> or an instance of <code>Schedulable</code>. The 075 * method first performs a feasibility analysis using the new scheduling 076 * characteristics of either <code>this</code> or the given instance of 077 * <code>Schedulable</code>. If the resulting system is feasible the method 078 * replaces the current sheduling characteristics, of either <code>this</code> 079 * or the given instance of <code>Schedulable</code> as appropriate, with the 080 * new scheduling characteristics. 081 * 082 * @param release The proposed release parameters. 083 * @param memory The proposed memory parameters. 084 * @return True, if the resulting system is feasible and the changes are made. 085 * False, if the resulting system is not feasible and no changes are made. 086 */ 087 public boolean setIfFeasible(ReleaseParameters release, MemoryParameters memory); 088 089 /** This method appears in many classes in the RTSJ and with various parameters. 090 * The parameters are either new scheduling characteristics for an instance of 091 * <code>Schedulable</code> or an instance of <code>Schedulable</code>. The 092 * method first performs a feasibility analysis using the new scheduling 093 * characteristics of either <code>this</code> or the given instance of 094 * <code>Schedulable</code>. If the resulting system is feasible the method 095 * replaces the current sheduling characteristics, of either <code>this</code> 096 * or the given instance of <code>Schedulable</code> as appropriate, with the 097 * new scheduling characteristics. 098 * 099 * @param release The proposed release parameters. 100 * @param memory The proposed memory parameters. 101 * @param group The proposed processing group parameters. 102 * @return True, if the resulting system is feasible and the changes are made. 103 * False, if the resulting system is not feasible and no changes are made. 104 */ 105 public boolean setIfFeasible(ReleaseParameters release, MemoryParameters memory, 106 ProcessingGroupParameters group); 107 108 /** This method appears in many classes in the RTSJ and with various parameters. 109 * The parameters are either new scheduling characteristics for an instance of 110 * <code>Schedulable</code> or an instance of <code>Schedulable</code>. The 111 * method first performs a feasibility analysis using the new scheduling 112 * characteristics of either <code>this</code> or the given instance of 113 * <code>Schedulable</code>. If the resulting system is feasible the method 114 * replaces the current sheduling characteristics, of either <code>this</code> 115 * or the given instance of <code>Schedulable</code> as appropriate, with the 116 * new scheduling characteristics. 117 * 118 * @param release The proposed release parameters. 119 * @param group The proposed processing group parameters. 120 * @return True, if the resulting system is fesible and the changes are made. 121 * False, if the resulting system is not feasible and no changes are made. 122 */ 123 public boolean setIfFeasible(ReleaseParameters release, ProcessingGroupParameters group); 124 125 /** Sets the memory parameters associated with this instance of <code>Schedulable</code>. 126 * 127 * @param memory A <code>MemoryParameters</code> object which will become the 128 * memory parameters associated with <code>this</code> after 129 * the method call. 130 */ 131 public void setMemoryParameters(MemoryParameters memory); 132 133 /** The method first performs a feasibility analysis using the given memory 134 * parameters as replacements for the memory parameters of <code>this</code>. 135 * If the resulting system is feasible the method replaces the current 136 * memory parameterers of <code>this</code> with the new memory parameters. 137 * 138 * @param memParam The proposed memory Parameters 139 * @return True, if the resulting system is feasible and the changes are made. 140 * False, if the resulting system is not feasible and no changes are made. 141 */ 142 public boolean setMemoryParametersIfFeasible(MemoryParameters memParam); 143 144 /** Sets the <code>ProcessingGroupParameters</code> of <code>this</code> only 145 * if the resulting set of scheduling and release characteristics is feasible. 146 * 147 * @param pgp The <code>ProcessingGroupParameters</code> object. If null, 148 * nothing happens. 149 * @return True, if the resulting system is feasible and the changes are made. 150 * False, if the resulting system is not feasible and no changes are made. 151 */ 152 public void setProcessingGroupParameters(ProcessingGroupParameters pgp); 153 154 /** Sets the <code>ProcessingGroupParameters</code> of <code>this</code> only 155 * if the resulting set of scheduling and release characteristics is feasible. 156 * 157 * @param groupParameters The <code>ProcessingGroupParameters</code> object. 158 * If null, nothing happens. 159 * @return True, if the resulting system is feasible and the changes are made. 160 * False, if the resulting system is not feasible and no changes are made. 161 */ 162 public boolean setProcessingGroupParametersIfFeasible(ProcessingGroupParameters groupParameters); 163 164 /** Sets the release parameters associated with this instance of <code>Schedulable</code>. 165 * Since this affects the constraints expressed in the release parameters of the 166 * existing schedulable objects, this may change the feasibility of the current schedule. 167 * 168 * @param release A <code>ReleaseParameters</code> object which will become the 169 * release parameters associated with this after the method call. 170 */ 171 public void setReleaseParameters(ReleaseParameters release); 172 173 /** Set the <code>ReleaseParameters</code> for this schedulable object only if 174 * the resulting set of scheduling and release characteristics is feasible. 175 * 176 * @param release The <code>ReleaseParameters</code> object. If null, nothing happens. 177 * @return True, if the resulting system is feasible and the changes are made. 178 * False, if the resulting system is not feasible and no changes are made. 179 */ 180 public boolean setReleaseParametersIfFeasible(ReleaseParameters release); 181 182 /** Sets the reference to the <code>SchedulingParameters</code> object. 183 * 184 * @param scheduling A reference to the <code>SchedulingParameters</code> object. 185 * @throws java.lang.IllegalThreadStateException Thrown when: 186 * <code>((Thread.isAlive() && 187 * Not Blocked) == true)</code>. 188 * (Where blocked means waiting in 189 * <code>Thread.wait(), Thread.join() 190 * </code> or <code>Thread.sleep()</code>). 191 */ 192 public void setSchedulingParameters(SchedulingParameters scheduling); 193 194 /** The method first performs a feasibility analysis using the given scheduling 195 * parameters as replacements for the scheduling parameters of <code>this</code>. 196 * If the resulting system is feasible the method replaces the current scheduling 197 * parameters of <code>this</code> with the new scheduling parameters. 198 * 199 * @param scheduling The proposed scheduling parameters. 200 * @return True, if the resulting system is feasible and the chagens are made. 201 * False, if the resulting system is not feasible and no changes are made. 202 */ 203 public boolean setSchedulingParametersIfFeasible(SchedulingParameters scheduling); 204 205 /** Sets the reference to the <code>Scheduler</code> object. 206 * 207 * @param scheduler A reference to the <code>Scheduler</code> object. 208 * @throws java.lang.IllegalThreadStateException Thrown when: 209 * <code>((Thread.isAlive() && 210 * Not Blocked) == true)</code>. 211 * (Where blocked means waiting 212 * in <code>Thread.wait(), 213 * Thread.join()</code> or 214 * <code>Thread.sleep()</code>). 215 */ 216 public void setScheduler(Scheduler scheduler) 217 throws IllegalThreadStateException; 218 219 /** Sets the reference to the <code>Scheduler</code> object. 220 * 221 * @param scheduler A reference to the <code>Scheduler</code> object. 222 * @param scheduling A reference to the <code>SchedulingParameters</code> which 223 * will be associated with <code>this</code>. If null, no 224 * changes to current value of this parameter is made. 225 * @param release A reference to the <code>ReleaseParameters</code> which will 226 * be associated with <code>this</code>. If null, no change to 227 * current value of this parameter is made. 228 * @param memoryParameters A reference to the <code>MemoryParaemters</code> 229 * which will be associated with <code>this</code>. If 230 * null, no change to current value of this parameter 231 * is made. 232 * @param processingGroup A reference to the <code>ProcessingGroupParameters</code> 233 * which will be associated with <code>this</code>. If null, 234 * no change to current value of this parameter is made. 235 * @throws java.lang.IllegalThreadStateException Thrown when: 236 * <code>((Thread.isAlive() && 237 * Not Blocked) == true)</code>. 238 * (Where blocked means waiting 239 * in <code>Thread.wait(), 240 * Thread.join()</code> or 241 * <code>Thread.sleep()</code>). 242 */ 243 public void setScheduler(Scheduler scheduler, 244 SchedulingParameters scheduling, 245 ReleaseParameters release, 246 MemoryParameters memoryParameters, 247 ProcessingGroupParameters processingGroup) 248 throws IllegalThreadStateException; 249 250 /** Return a UID for this Schedulable object. */ 251 public long getUID(); 252 253 }