public abstract class Task
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
MAX_HRT_TASK_PRIORITY |
static int |
MIN_HRT_TASK_PRIORITY |
Constructor and Description |
---|
Task(java.lang.String name,
long periodMin,
int priority)
Creates a cyclic task with a deadline equals to
periodMin . |
Task(java.lang.String name,
long periodMin,
long deadline,
int priority)
Creates a cyclic task.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Thread |
asThread() |
static Task |
currentTask()
Returns a reference to the currently executing Task object.
If the current thread is not a Task instance, this method returns null. |
long |
getCurrentWCA() |
static long |
getCurrentWCA(int taskUID)
Calls the
getCurrentWCA() method of the task with the specified UID. |
long |
getCurrentWCET() |
static long |
getCurrentWCET(int taskUID)
Calls the
getCurrentWCET() method of the task with the specified UID. |
long |
getDeadline()
Gets the deadline of the task.
|
java.lang.String |
getName()
Gets the name of the task.
|
int |
getNbDeadlinesReached() |
static int |
getNbDeadlinesReached(int taskUID)
Calls the
getNbDeadlinesReached() method of the task with the specified UID. |
long |
getPeriod()
Gets the minimum period of the task.
|
int |
getPriority()
Gets the priority of the task.
|
int |
getUID()
Gets the unique ID of this task.
|
boolean |
isInRescueMode()
Tests if this task is in rescue mode.
|
static boolean |
isInRescueMode(int taskUID)
Calls the
isInRescueMode() method of the task with the specified UID. |
void |
outOfResource(DeadlineException exception)
Method called when this Task terminates due to the given uncaught DeadlineException exception.
|
void |
outOfResource(WCAException exception)
Method called when this Task terminates due to the given uncaught WCAException exception.
|
static void |
registerCyclicTask(int taskUID,
long increment,
long period)
Calls the
registerCyclicTask(long, long) method of the task with the specified UID. |
void |
registerCyclicTask(long increment,
long period)
Starts a task cycle in increment nanoseconds and then every period nanoseconds.
If the task is already registered as a cyclic task, this method modifies timing configuration. |
abstract void |
run()
Starting the task causes this method
run() to be called
in a separately executing thread. |
void |
start()
Starts a task cycle.
|
static void |
start(int id)
Calls the
start() method of the task with the specified UID. |
static void |
start(Task[] tasks)
Starts all the provided tasks at the very same time.
|
void |
uncaughtException(java.lang.Throwable exception)
Method called when this Task terminates due to the given uncaught exception.
|
void |
unregisterCyclicTask()
Disables the automatic start for this task.
|
static void |
unregisterCyclicTask(int taskUID)
Calls the
unregisterCyclicTask() method of the task with the specified UID. |
public static final int MIN_HRT_TASK_PRIORITY
public static final int MAX_HRT_TASK_PRIORITY
public Task(java.lang.String name, long periodMin, int priority)
periodMin
.
Equivalent to new Task(name, periodMin, periodMin, priority)
.name
- the name of the taskperiodMin
- the minimum period of the task (in nanoseconds)java.lang.IllegalArgumentException
- if the given priority is not in the range MIN_HRT_TASK_PRIORITY
to MAX_HRT_TASK_PRIORITY.HRTException
- if the system is not in initialization mode.public Task(java.lang.String name, long periodMin, long deadline, int priority)
deadline
is equals to 0, system will not check for deadline
exception for this task.name
- the name of the taskperiodMin
- the minimum period of the task (in nanoseconds)deadline
- the duration of the deadline of the task (in nanoseconds)java.lang.IllegalArgumentException
- if deadline is higher than periodMinjava.lang.IllegalArgumentException
- if the given priority is not in the range MIN_HRT_TASK_PRIORITY
to MAX_HRT_TASK_PRIORITY.HRTException
- if the system is not in initialization mode.public java.lang.String getName()
public int getPriority()
public long getPeriod()
public long getDeadline()
public final void start()
HRTException
- if the task is registered as cyclic taskpublic static void start(Task[] tasks)
HRTException
- if one the tasks is registered as cyclic taskpublic abstract void run()
run()
to be called
in a separately executing thread.
Subclasses of Task must override this method.public void outOfResource(WCAException exception)
exception
- the exceptionpublic void outOfResource(DeadlineException exception)
exception
- the exceptionpublic void uncaughtException(java.lang.Throwable exception)
exception
- the exceptionpublic int getUID()
public static void start(int id)
start()
method of the task with the specified UID.id
- the unique ID of the task to startjava.lang.IllegalArgumentException
- if the specified UID is not validHRTException
- if the task is registered as cyclic taskpublic void registerCyclicTask(long increment, long period)
increment
- time before first start in nanosecondsperiod
- time between each starts in nanosecondsPeriodException
- if period
is lower than period of this task.public void unregisterCyclicTask()
public boolean isInRescueMode()
public long getCurrentWCET()
public long getCurrentWCA()
public int getNbDeadlinesReached()
public java.lang.Thread asThread()
public static void registerCyclicTask(int taskUID, long increment, long period)
registerCyclicTask(long, long)
method of the task with the specified UID.taskUID
- the unique ID of the taskjava.lang.IllegalArgumentException
- if the specified UID is not validpublic static void unregisterCyclicTask(int taskUID)
unregisterCyclicTask()
method of the task with the specified UID.taskUID
- the unique ID of the taskjava.lang.IllegalArgumentException
- if the specified UID is not validpublic static boolean isInRescueMode(int taskUID)
isInRescueMode()
method of the task with the specified UID.taskUID
- the unique ID of the taskjava.lang.IllegalArgumentException
- if the specified UID is not validpublic static long getCurrentWCET(int taskUID)
getCurrentWCET()
method of the task with the specified UID.taskUID
- the unique ID of the taskjava.lang.IllegalArgumentException
- if the specified UID is not validpublic static long getCurrentWCA(int taskUID)
getCurrentWCA()
method of the task with the specified UID.taskUID
- the unique ID of the taskjava.lang.IllegalArgumentException
- if the specified UID is not validpublic static int getNbDeadlinesReached(int taskUID)
getNbDeadlinesReached()
method of the task with the specified UID.taskUID
- the unique ID of the taskjava.lang.IllegalArgumentException
- if the specified UID is not validpublic static Task currentTask()