Class TheSimulator

java.lang.Object
   |
   +----Simulator
           |
           +----TheSimulator

public class TheSimulator
extends Simulator
implements EventDestination
A subclass of Simulator

See Also:
Simulator

Constructor Index

 o TheSimulator(String[])
Constructor.

Method Index

 o allIdleProcessors()
Return an array with id's for the currently idle processors
 o callJobArrival(float, int)
Calls the SchedulerInterface routine JobArrival in the scheduler
 o callTaskStateChange(float, long)
Calls the SchedulerInterface routine TaskStateChange in the scheduler
 o getJobId(long)
 o getJobTypeId(int)
 o getNeighbours(int)
Returns the neighbours of a processor
 o getNetwork()
Return the object Network.
 o getPEId(long)
Returns the id of the processor on which task with taskId resides
 o getTask(long)
Return the object task corresponding to a given id.
 o handleEvent(SimEvent)
Overrides handleEvent in Simulator.
 o jobClass(int)
Returns user defined job class
 o jobs()
Returns an array with global job identifiers for all jobs managed by this object
 o jobsWithLeastTasks()
Returns an array with global job identifiers for jobs, managed by this object, with least number of tasks
 o jobsWithLeastTasks(int)
Returns an array with global job identifiers for jobs, managed by this object, with least number of tasks in the given state
 o jobsWithMostTasks()
Returns an array with global job identifiers for jobs, managed by this object, with most number of tasks
 o jobsWithMostTasks(int)
Returns an array with global job identifiers for jobs, managed by this object, with most number of tasks in the given state
 o nrIdleProcessors()
Return the number of idle processors in the current network
 o nrProcessors()
Return the number of processors in the current network
 o numberOfJobs()
Returns the number of jobs managed by this object
 o numberOfTasks()
Returns the total number of tasks, contained by jobs managed by this object
 o numberOfTasks(int)
Returns the number of tasks in the given state, contained by jobs managed by this object
 o numberOfTasksInJob(int)
Returns the number of tasks contained by the given job
 o numberOfTasksInJob(int, int)
Returns the number of tasks in the given state, contained by the given job
 o numberOfTasksInJobOnPE(int, int)
Returns the number of tasks on the given processing element, contained by the given job.
 o numberOfTasksInJobOnPE(int, int, int)
Returns the number of tasks on the given processing element in the given state, contained by the given job.
 o PreemptStatistics(int, float)
 o printStatistics()
 o processEvent(SimEvent)
Overrides method in Simulator.
 o regScheduler(SchedulerInterface)
Registers an instance of the Scheduler class in the simulator
 o removeEventsToTask(long)
 o scheduleTask(int, long, float, float)
Schedules a task at a processor at a certain time
 o start()
Starts the simulation
 o stateOfTask(long)
Return the state of a task
 o stop()
Overrides stop method in Simulator.
 o tasks()
Returns an array with global task identifiers for tasks, contained by jobs managed by this object.
 o tasks(int)
Returns an array with global task identifiers for tasks in the given state, contained by jobs managed by this object.
 o tasksInJob(int)
Returns an array with global task identifiers for tasks contained by the given job.
 o tasksInJob(int, int)
Returns an array with global task identifiers for tasks in the given state contained by the given job.
 o tasksInJobOnPE(int, int)
Returns an array with global task identifiers for all tasks on the given processing element, contained by the given job.
 o tasksInJobOnPE(int, int, int)
Returns an array with global task identifiers for all tasks on the given processing element in the given state, contained by the given job.

Constructors

 o TheSimulator
 public TheSimulator(String args[])
Constructor.

Parameters:
arguments - Runtime arguments supplied
See Also:
Network, Job1

Methods

 o regScheduler
 public void regScheduler(SchedulerInterface sched)
Registers an instance of the Scheduler class in the simulator

Parameters:
sched - An instance of the Scheduler class
See Also:
Scheduler
 o start
 public void start()
Starts the simulation

Overrides:
start in class Simulator
 o stop
 public void stop()
Overrides stop method in Simulator. Called when the simulation has ended i.e no more events to process

Overrides:
stop in class Simulator
See Also:
Simulator
 o printStatistics
 public void printStatistics()
 o processEvent
 public void processEvent(SimEvent e)
Overrides method in Simulator. Forwards End Of Timeslice events to the registered scheduler by calling EndOfTimeSlice method in the Scheduler class. Also prints out event information using the event's toString-method.

Parameters:
e - An instance of the SimEvent class
Overrides:
processEvent in class Simulator
See Also:
SimEvent, Scheduler
 o PreemptStatistics
 public void PreemptStatistics(int PeId,
                               float time)
 o handleEvent
 public void handleEvent(SimEvent e)
Overrides handleEvent in Simulator.

Parameters:
e - An instance of SimEvent
See Also:
Simulator, SimEvent
 o removeEventsToTask
 protected void removeEventsToTask(long taskId)
 o scheduleTask
 public void scheduleTask(int PeId,
                          long taskId,
                          float time,
                          float period)
Schedules a task at a processor at a certain time

Parameters:
PeId - Processor ID
taskId - Task ID
time - Time to schedule task
 o numberOfJobs
 public int numberOfJobs()
Returns the number of jobs managed by this object

Returns:
the number of jobs managed by this object
 o numberOfTasks
 public int numberOfTasks()
Returns the total number of tasks, contained by jobs managed by this object

Returns:
the total number of tasks, contained by jobs managed by this objec
 o numberOfTasks
 public int numberOfTasks(int state)
Returns the number of tasks in the given state, contained by jobs managed by this object

Parameters:
taskState - a task state.
Returns:
the number of tasks in the given state, contained by jobs managed by this object
 o numberOfTasksInJob
 public int numberOfTasksInJob(int jobId)
Returns the number of tasks contained by the given job

Parameters:
jobId - a global job identifier
Returns:
the number of tasks contained by the given job
Throws: IllegalArgumentException
if the given job is not managed by this object
 o jobClass
 public String jobClass(int jobId)
Returns user defined job class

Parameters:
jobId - a global job identifier
Returns:
the string describing job
Throws: IllegalArgumentException
if the given job is not managed by this object
 o numberOfTasksInJob
 public int numberOfTasksInJob(int jobId,
                               int taskState)
Returns the number of tasks in the given state, contained by the given job

Parameters:
jobId - a global job identifier
taskState - a task state
Returns:
the number of tasks in the given state, contained by the given job
Throws: IllegalArgumentException
if the given job is not managed by this object
 o tasksInJob
 public long[] tasksInJob(int jobId)
Returns an array with global task identifiers for tasks contained by the given job.

Parameters:
jobId - a global job identifier.
Returns:
an array with global task identifiers for tasks contained by the given job.
Throws: IllegalArgumentException
if the given job is not managed by this object.
 o tasksInJob
 public long[] tasksInJob(int jobId,
                          int taskState)
Returns an array with global task identifiers for tasks in the given state contained by the given job.

Parameters:
jobId - a global job identifier.
Returns:
an array with global task identifiers for tasks in the given statecontained by the given job.
Throws: IllegalArgumentException
if the given job is not managed by this object.
 o tasks
 public long[] tasks()
Returns an array with global task identifiers for tasks, contained by jobs managed by this object.

Returns:
an array with global task identifiers for tasks, contained by jobs managed by this object
 o tasks
 public long[] tasks(int state)
Returns an array with global task identifiers for tasks in the given state, contained by jobs managed by this object.

Parameters:
state - a task state
Returns:
an array with global task identifiers for tasks in the given state, contained by jobs managed by this object
 o jobs
 public int[] jobs()
Returns an array with global job identifiers for all jobs managed by this object

Returns:
an array with global job identifiers for all jobs managed by this object
 o jobsWithLeastTasks
 public int[] jobsWithLeastTasks()
Returns an array with global job identifiers for jobs, managed by this object, with least number of tasks

Returns:
an array with global job identifiers for jobs, managed by this object, with least number of tasks
 o jobsWithMostTasks
 public int[] jobsWithMostTasks()
Returns an array with global job identifiers for jobs, managed by this object, with most number of tasks

Returns:
an array with global job identifiers for jobs, managed by this object, with most number of tasks
 o jobsWithLeastTasks
 public int[] jobsWithLeastTasks(int state)
Returns an array with global job identifiers for jobs, managed by this object, with least number of tasks in the given state

Parameters:
state - - a task state
Returns:
an array with global job identifiers for jobs, managed by this object, with least number of tasks in the given state
 o jobsWithMostTasks
 public int[] jobsWithMostTasks(int state)
Returns an array with global job identifiers for jobs, managed by this object, with most number of tasks in the given state

Parameters:
state - - a task state
Returns:
an array with global job identifiers for jobs, managed by this object, with most number of tasks in the given state
 o nrProcessors
 public int nrProcessors()
Return the number of processors in the current network

Returns:
the number of processors in the current network
 o nrIdleProcessors
 public int nrIdleProcessors()
Return the number of idle processors in the current network

Returns:
the number of idle processors in the current network
 o allIdleProcessors
 public int[] allIdleProcessors()
Return an array with id's for the currently idle processors

Returns:
an array with id's for the currently idle processors
 o getPEId
 public int getPEId(long taskId)
Returns the id of the processor on which task with taskId resides

Parameters:
taskId - Task identifier
Returns:
Processor identifier
 o numberOfTasksInJobOnPE
 public int numberOfTasksInJobOnPE(int jobId,
                                   int peId)
Returns the number of tasks on the given processing element, contained by the given job.

Parameters:
jobId - a global job identifier.
peId - a processing element identifier.
Returns:
the number of tasks on the given processing element, contained by the given job.
Throws: IllegalArgumentException
if the given job is not managed by this object.
See Also:
Job, Task
 o tasksInJobOnPE
 public long[] tasksInJobOnPE(int jobId,
                              int peId)
Returns an array with global task identifiers for all tasks on the given processing element, contained by the given job.

Parameters:
jobId - a global job identifier.
peId - a processing element identifier.
Returns:
an array with global task identifiers for all tasks on the given processing element, contained by the given job.
Throws: IllegalArgumentException
if the given job is not managed by this object.
See Also:
Task
 o tasksInJobOnPE
 public long[] tasksInJobOnPE(int jobId,
                              int peId,
                              int taskState)
Returns an array with global task identifiers for all tasks on the given processing element in the given state, contained by the given job.

Parameters:
jobId - a global job identifier.
peId - a processing element identifier.
taskState - a task state.
Returns:
an array with global task identifiers for all tasks on the given processing element in the given state, contained by the given job.
Throws: IllegalArgumentException
if the given job is not managed by this object.
See Also:
Task
 o numberOfTasksInJobOnPE
 public int numberOfTasksInJobOnPE(int jobId,
                                   int peId,
                                   int taskState)
Returns the number of tasks on the given processing element in the given state, contained by the given job.

Parameters:
jobId - a global job identifier.
peId - a processing element identifier.
taskState - a task state.
Returns:
the number of tasks on the given processing element in the given state, contained by the given job.
Throws: IllegalArgumentException
if the given job is not managed by this object.
See Also:
Job, Task
 o getNeighbours
 public int[] getNeighbours(int PeId)
Returns the neighbours of a processor

Parameters:
PeId - The id of the processor
Returns:
An array with the id's of the neighbour processors
 o stateOfTask
 public int stateOfTask(long taskId)
Return the state of a task

Parameters:
The - task id
Returns:
The state of the task
 o getJobId
 public int getJobId(long taskId)
 o getJobTypeId
 public int getJobTypeId(int jobId)
 o getNetwork
 public Network getNetwork()
Return the object Network. Overrides method in Simulator.java

Returns:
the Task
Overrides:
getNetwork in class Simulator
See Also:
Task
 o getTask
 public Task getTask(long taskId)
Return the object task corresponding to a given id.

Parameters:
Task - Id
Returns:
the Task
See Also:
Task
 o callJobArrival
 public void callJobArrival(float time,
                            int jobID)
Calls the SchedulerInterface routine JobArrival in the scheduler

Parameters:
time - Arrival time of the new job
jobID - the id of the new job
See Also:
JobManager
 o callTaskStateChange
 public void callTaskStateChange(float time,
                                 long taskID)
Calls the SchedulerInterface routine TaskStateChange in the scheduler

Parameters:
time - time when the change of state occurred
taskID - id of the task
See Also:
Task